commit f815cdce4bc713c49b65f67c7688800fc7b2a125 Author: Sanchayan Maity Date: Wed Apr 12 14:35:53 2017 +0530 Initial Commit Preliminary commit with the following projects in Eclipse 1. gtkmm Hello World 2. PCF8574 I2C GPIO Expander 3. PCF8591 I2C A-D & D-A Converter 4. SPI based OLED Display with SSD1306 controller Library Dependencies 1. Gtk 2. Gtkmm 3. libsoc TODO: Documentation and cleanup diff --git a/gtkmm/.cproject b/gtkmm/.cproject new file mode 100644 index 0000000..58b3697 --- /dev/null +++ b/gtkmm/.cproject @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gtkmm/.gitignore b/gtkmm/.gitignore new file mode 100644 index 0000000..3df573f --- /dev/null +++ b/gtkmm/.gitignore @@ -0,0 +1 @@ +/Debug/ diff --git a/gtkmm/.project b/gtkmm/.project new file mode 100644 index 0000000..af7875e --- /dev/null +++ b/gtkmm/.project @@ -0,0 +1,27 @@ + + + gtkmm + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/gtkmm/.settings/language.settings.xml b/gtkmm/.settings/language.settings.xml new file mode 100644 index 0000000..cd4dccd --- /dev/null +++ b/gtkmm/.settings/language.settings.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gtkmm/hello_world.cpp b/gtkmm/hello_world.cpp new file mode 100644 index 0000000..3dd18cd --- /dev/null +++ b/gtkmm/hello_world.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +#include + +class HelloWorld : public Gtk::Window +{ + public: + HelloWorld(); + virtual ~HelloWorld(); + + protected: + //Signal handlers: + void on_button_clicked(); + + //Member widgets: + Gtk::Button m_button; +}; + +HelloWorld::HelloWorld() +: m_button("Hello World") // creates a new button with label "Hello World". +{ + // Sets the border width of the window. + set_border_width(10); + + // When the button receives the "clicked" signal, it will call the + // on_button_clicked() method defined below. + m_button.signal_clicked().connect(sigc::mem_fun(*this, + &HelloWorld::on_button_clicked)); + + // This packs the button into the Window (a container). + add(m_button); + + // The final step is to display this newly created widget... + m_button.show(); +} + +HelloWorld::~HelloWorld() +{ + +} + +void HelloWorld::on_button_clicked() +{ + std::cout << "Hello World" << std::endl; +} + +int main (int argc, char *argv[]) +{ + Gtk::Main kit(argc, argv); + + HelloWorld helloworld; + + //Shows the window and returns when it is closed. + Gtk::Main::run(helloworld); + + return 0; +} diff --git a/pcf8574/.cproject b/pcf8574/.cproject new file mode 100644 index 0000000..7ed724e --- /dev/null +++ b/pcf8574/.cproject @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcf8574/.gitignore b/pcf8574/.gitignore new file mode 100644 index 0000000..3df573f --- /dev/null +++ b/pcf8574/.gitignore @@ -0,0 +1 @@ +/Debug/ diff --git a/pcf8574/.project b/pcf8574/.project new file mode 100644 index 0000000..2a17711 --- /dev/null +++ b/pcf8574/.project @@ -0,0 +1,26 @@ + + + pcf8574 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/pcf8574/.settings/language.settings.xml b/pcf8574/.settings/language.settings.xml new file mode 100644 index 0000000..1ed03a0 --- /dev/null +++ b/pcf8574/.settings/language.settings.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/pcf8574/pcf8574.c b/pcf8574/pcf8574.c new file mode 100644 index 0000000..cc6a2ea --- /dev/null +++ b/pcf8574/pcf8574.c @@ -0,0 +1,135 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +/* PCF8574 I2C Address on Pioneer 600 */ +#define PCF8574_ADDRESS 0x20 + +static uint8_t RS = 0x01; +static uint8_t EN = 0x04; +static uint8_t BL = 0x08; + +/* + * libsoc i2c API Documentation: http://jackmitch.github.io/libsoc/c/i2c/#i2c + */ + +int pulse_enable(i2c *i2c, uint8_t data) +{ + uint32_t ret; + uint8_t buf[4] = {0}; + + buf[0] = data | EN; + ret = libsoc_i2c_write(i2c, buf, 1); + if (ret == EXIT_FAILURE) + return ret; + + usleep(1); + + buf[0] = data & ~EN; + ret = libsoc_i2c_write(i2c, buf, 1); + + return ret; +} + +int pcf8574_write_cmd4(i2c *i2c, uint8_t command) +{ + uint32_t ret; + uint8_t buf[4] = {0}; + + buf[0] = command | BL; + ret = libsoc_i2c_write(i2c, buf, 1); + if (ret == EXIT_FAILURE) + return ret; + + ret = pulse_enable(i2c, command | BL); + if (ret == EXIT_FAILURE) + perror("Pulse enable failed\n"); + + return ret; +} + +int pcf8574_write_cmd8(i2c *i2c, uint8_t command) +{ + uint32_t ret; + uint8_t command_H = command & 0xf0; + uint8_t command_L = (command << 4) & 0xf0; + + ret = pcf8574_write_cmd4(i2c, command_H); + if (ret == EXIT_FAILURE) { + perror("Failed to write command high 4 bits"); + return ret; + } + + ret = pcf8574_write_cmd4(i2c, command_L); + if (ret == EXIT_FAILURE) { + perror("Failed to write command low 4 bits"); + return ret; + } + + return EXIT_SUCCESS; +} + +int pcf8574_write_data4(i2c *i2c, uint8_t data) +{ + uint32_t ret; + uint8_t buf[4] = {0}; + + buf[0] = data | RS | BL; + ret = libsoc_i2c_write(i2c, buf, 1); + if (ret == EXIT_FAILURE) + return ret; + + ret = pulse_enable(i2c, data | RS | BL); + if (ret == EXIT_FAILURE) + perror("Pulse enable failed\n"); + + return ret; +} + +int pcf8574_write_data8(i2c *i2c, uint8_t data) +{ + uint8_t ret; + uint8_t data_H = data & 0xf0; + uint8_t data_L = (data << 4) & 0xf0; + + ret = pcf8574_write_data4(i2c, data_H); + if (ret == EXIT_FAILURE) { + perror("Failed to write data high 4 bits"); + return ret; + } + + ret = pcf8574_write_data4(i2c, data_L); + if (ret == EXIT_FAILURE) { + perror("Failed to write data low 4 bits"); + return ret; + } + + return ret; +} + +i2c* pcf8574_init(uint8_t i2c_bus, uint8_t i2c_address) +{ + return libsoc_i2c_init(i2c_bus, i2c_address); +} + +int pcf8574_close(i2c *i2c) +{ + return libsoc_i2c_free(i2c); +} + +int main(void) +{ + i2c *i2c_pcf8574; + + i2c_pcf8574 = pcf8574_init(0, PCF8574_ADDRESS); + pcf8574_write_data8(i2c_pcf8574, 0xff); + + pcf8574_close(i2c_pcf8574); + + return 0; +} diff --git a/pcf8591/.cproject b/pcf8591/.cproject new file mode 100644 index 0000000..79e7752 --- /dev/null +++ b/pcf8591/.cproject @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcf8591/.gitignore b/pcf8591/.gitignore new file mode 100644 index 0000000..3df573f --- /dev/null +++ b/pcf8591/.gitignore @@ -0,0 +1 @@ +/Debug/ diff --git a/pcf8591/.project b/pcf8591/.project new file mode 100644 index 0000000..a9fd652 --- /dev/null +++ b/pcf8591/.project @@ -0,0 +1,26 @@ + + + pcf8591 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/pcf8591/.settings/language.settings.xml b/pcf8591/.settings/language.settings.xml new file mode 100644 index 0000000..dd67591 --- /dev/null +++ b/pcf8591/.settings/language.settings.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/pcf8591/pcf8591.c b/pcf8591/pcf8591.c new file mode 100644 index 0000000..26c4f96 --- /dev/null +++ b/pcf8591/pcf8591.c @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PCF8591_ADDRESS 0x48 + +int main( int argc, char **argv ) +{ + uint8_t i; + uint32_t fd; + uint32_t ret; + uint8_t command[2]; + uint8_t value[4]; + useconds_t delay = 2000; + + char *dev = "/dev/i2c-0"; + + printf("PCF8591 ADC and DAC test code\n"); + + fd = open(dev, O_RDWR); + if(fd < 0) { + perror("Opening i2c device node\n"); + return 1; + } + + ret = ioctl(fd, I2C_SLAVE, PCF8591_ADDRESS); + if(ret < 0) { + perror("Selecting i2c device\n"); + } + + while (true) { + for(i = 0; i < 4; i++) { + + /* + * Analog output enable | Read Input i + * See Page 6 of NXP PCF8591 data sheet + */ + command[0] = 0x40 | ((i + 1) & 0x03); /* Control Byte */ + command[1]++; /* DAC Data Register */ + + ret = write(fd, &command, 2); + if (ret != 2) + perror("writing i2c device"); + + usleep(delay); + + /* the read is always one step behind the selected input */ + ret = read(fd, &value[i], 1); + if(ret != 1) + perror("reading i2c device"); + + usleep(delay); + } + + printf("0x%02x 0x%02x 0x%02x 0x%02x\n", value[0], value[1], value[2], value[3]); + sleep(1); + } + + close(fd); + return(0); +} diff --git a/ssd1306/.cproject b/ssd1306/.cproject new file mode 100644 index 0000000..e4aa9c3 --- /dev/null +++ b/ssd1306/.cproject @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ssd1306/.gitignore b/ssd1306/.gitignore new file mode 100644 index 0000000..3df573f --- /dev/null +++ b/ssd1306/.gitignore @@ -0,0 +1 @@ +/Debug/ diff --git a/ssd1306/.project b/ssd1306/.project new file mode 100644 index 0000000..f1c2726 --- /dev/null +++ b/ssd1306/.project @@ -0,0 +1,26 @@ + + + ssd1306 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/ssd1306/.settings/language.settings.xml b/ssd1306/.settings/language.settings.xml new file mode 100644 index 0000000..e8a980d --- /dev/null +++ b/ssd1306/.settings/language.settings.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/ssd1306/oled.c b/ssd1306/oled.c new file mode 100644 index 0000000..4727202 --- /dev/null +++ b/ssd1306/oled.c @@ -0,0 +1,106 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "ssd1306.h" + +#define GPIO_DC 82 /* SODIMM 32 */ +#define GPIO_RES 31 /* SODIMM 67 */ + +#define SPI_DEVICE 1 +#define CHIP_SELECT 0 + +char value[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; + +int main(int argc,char **argv) +{ + time_t now; + struct tm *timenow; + ssd1306 *oled; + + printf("OLED Test Program !!!\n"); + + oled = malloc(sizeof(ssd1306)); + if (!oled) + exit(ENOMEM); + + oled->dc = libsoc_gpio_request(GPIO_DC, LS_SHARED); + oled->res = libsoc_gpio_request(GPIO_RES, LS_SHARED); + + if (oled->dc == NULL || oled->res == NULL) + goto fail; + + libsoc_gpio_set_direction(oled->dc, OUTPUT); + libsoc_gpio_set_direction(oled->res, OUTPUT); + if (libsoc_gpio_get_direction(oled->dc) != OUTPUT || + libsoc_gpio_get_direction(oled->res) != OUTPUT) { + + printf("Failed to set direction to OUTPUT\n"); + goto fail; + } + + oled->switch_capvcc = 0; + + oled->spi_dev = libsoc_spi_init(SPI_DEVICE, CHIP_SELECT); + + if (!oled->spi_dev) { + printf("Failed to get spidev device!\n"); + return EXIT_FAILURE; + } + + libsoc_spi_set_mode(oled->spi_dev, MODE_0); + libsoc_spi_get_mode(oled->spi_dev); + + libsoc_spi_set_speed(oled->spi_dev, 2000000); + libsoc_spi_get_speed(oled->spi_dev); + + libsoc_spi_set_bits_per_word(oled->spi_dev, BITS_8); + libsoc_spi_get_bits_per_word(oled->spi_dev); + + SSD1306_begin(oled); + SSD1306_clear(oled); + + while(1) { + time(&now); + timenow = localtime(&now); + + SSD1306_bitmap(oled, 0, 2, Singal816, 16, 8); + SSD1306_bitmap(oled, 24, 2, Bluetooth88, 8, 8); + SSD1306_bitmap(oled, 40, 2, Msg816, 16, 8); + SSD1306_bitmap(oled, 64, 2, GPRS88, 8, 8); + SSD1306_bitmap(oled, 90, 2, Alarm88, 8, 8); + SSD1306_bitmap(oled, 112, 2, Bat816, 16, 8); + + SSD1306_string(oled, 0, 52, "MUSIC", 12, 0); + SSD1306_string(oled, 52, 52, "MENU", 12, 0); + SSD1306_string(oled, 98, 52, "PHONE", 12, 0); + + SSD1306_char3216(oled, 0,16, value[timenow->tm_hour/10]); + SSD1306_char3216(oled, 16,16, value[timenow->tm_hour%10]); + SSD1306_char3216(oled, 32,16, ':'); + SSD1306_char3216(oled, 48,16, value[timenow->tm_min/10]); + SSD1306_char3216(oled, 64,16, value[timenow->tm_min%10]); + SSD1306_char3216(oled, 80,16, ':'); + SSD1306_char3216(oled, 96,16, value[timenow->tm_sec/10]); + SSD1306_char3216(oled, 112,16, value[timenow->tm_sec%10]); + + SSD1306_display(oled); + } + + libsoc_spi_free(oled->spi_dev); + libsoc_gpio_free(oled->res); + libsoc_gpio_free(oled->dc); + + fail: + if (oled->dc) + libsoc_gpio_free(oled->dc); + + if (oled->res) + libsoc_gpio_free(oled->res); + + return 0; +} diff --git a/ssd1306/ssd1306.c b/ssd1306/ssd1306.c new file mode 100644 index 0000000..7ca42ee --- /dev/null +++ b/ssd1306/ssd1306.c @@ -0,0 +1,226 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libsoc_spi.h" +#include "libsoc_gpio.h" +#include "ssd1306.h" + +#define width 128 +#define height 64 +#define pages 8 + +void command(ssd1306 *oled, char cmd) +{ + uint8_t command[1] = {0}; + + command[0] = cmd; + libsoc_gpio_set_level(oled->dc, LOW); + libsoc_spi_write(oled->spi_dev, command, 1); +} + +void SSD1306_begin(ssd1306 *oled) +{ + libsoc_gpio_set_level(oled->res, HIGH); + usleep(1000); + libsoc_gpio_set_level(oled->res, LOW); + usleep(1000); + libsoc_gpio_set_level(oled->res, HIGH); + + command(oled, SSD1306_DISPLAYOFF); + command(oled, SSD1306_SETDISPLAYCLOCKDIV); + command(oled, 0x80); /* the suggested ratio 0x80 */ + + command(oled, SSD1306_SETMULTIPLEX); + command(oled, 0x3F); + command(oled, SSD1306_SETDISPLAYOFFSET); + command(oled, 0x0); /* no offset */ + command(oled, SSD1306_SETSTARTLINE | 0x0); /* line #0 */ + command(oled, SSD1306_CHARGEPUMP); + command(oled, (oled->switch_capvcc == SSD1306_EXTERNALVCC) ? 0x10 : 0x14); + + command(oled, SSD1306_MEMORYMODE); + command(oled, 0x00); /* 0x0 act like ks0108 */ + + command(oled, SSD1306_SEGREMAP | 0x1); + command(oled, SSD1306_COMSCANDEC); + command(oled, SSD1306_SETCOMPINS); + command(oled, 0x12); /* TODO - calculate based on _rawHieght ? */ + command(oled, SSD1306_SETCONTRAST); + command(oled, (oled->switch_capvcc == SSD1306_EXTERNALVCC) ? 0x9F : 0xCF); + command(oled, SSD1306_SETPRECHARGE); + command(oled, (oled->switch_capvcc == SSD1306_EXTERNALVCC) ? 0x22 : 0xF1); + command(oled, SSD1306_SETVCOMDETECT); + command(oled, 0x40); + command(oled, SSD1306_DISPLAYALLON_RESUME); + command(oled, SSD1306_NORMALDISPLAY); + command(oled, SSD1306_DISPLAYON); +} + +void SSD1306_clear(ssd1306 *oled) +{ + int i; + + for(i = 0; i < sizeof(oled->buffer); i++) { + oled->buffer[i] = 0; + } +} + +void SSD1306_pixel(ssd1306 *oled, + int x, + int y, + char color) +{ + if (x > width || y > height) + return ; + + if (color) + oled->buffer[x+(y/8)*width] |= 1<<(y%8); + else + oled->buffer[x+(y/8)*width] &= ~(1<<(y%8)); +} + +void SSD1306_char1616(ssd1306 *oled, + uint8_t x, + uint8_t y, + uint8_t chChar) +{ + uint8_t i, j; + uint8_t chTemp = 0, y0 = y, chMode = 0; + + for (i = 0; i < 32; i ++) { + chTemp = Font1612[chChar - 0x30][i]; + for (j = 0; j < 8; j ++) { + chMode = chTemp & 0x80? 1 : 0; + SSD1306_pixel(oled, x, y, chMode); + chTemp <<= 1; + y ++; + if ((y - y0) == 16) { + y = y0; + x ++; + break; + } + } + } +} + +void SSD1306_char3216(ssd1306 *oled, + uint8_t x, + uint8_t y, + uint8_t chChar) +{ + uint8_t i, j; + uint8_t chTemp = 0, y0 = y, chMode = 0; + + for (i = 0; i < 64; i ++) { + chTemp = Font3216[chChar - 0x30][i]; + for (j = 0; j < 8; j ++) { + chMode = chTemp & 0x80 ? 1 : 0; + SSD1306_pixel(oled, x, y, chMode); + chTemp <<= 1; + y ++; + if ((y - y0) == 32) { + y = y0; + x ++; + break; + } + } + } +} + +void SSD1306_char(ssd1306 *oled, + unsigned char x, + unsigned char y, + char acsii, + char size, + char mode) +{ + char temp; + unsigned char i, j, y0 = y; + unsigned char ch = acsii - ' '; + + for(i = 0; i < size; i++) { + if (size == 12) { + if (mode)temp = Font1206[ch][i]; + else temp = ~Font1206[ch][i]; + } else { + if (mode) + temp = Font1608[ch][i]; + else + temp = ~Font1608[ch][i]; + } + for(j = 0; j < 8; j++) { + if (temp & 0x80) + SSD1306_pixel(oled, x, y, 1); + else + SSD1306_pixel(oled, x, y, 0); + + temp <<= 1; + y++; + + if ((y - y0) == size) { + y = y0; + x++; + break; + } + } + } +} + +void SSD1306_string(ssd1306 *oled, + uint8_t x, + uint8_t y, + const char *pString, + uint8_t Size, + uint8_t Mode) +{ + while (*pString != '\0') { + if (x > (width - Size / 2)) { + x = 0; + y += Size; + if (y > (height - Size)) { + y = x = 0; + } + } + + SSD1306_char(oled, x, y, *pString, Size, Mode); + x += Size / 2; + pString ++; + } +} + +void SSD1306_bitmap(ssd1306 *oled, + unsigned char x, + unsigned char y, + const unsigned char *pBmp, + char chWidth, + char chHeight) +{ + unsigned char i, j, byteWidth = (chWidth + 7) / 8; + + for (j = 0; j < chHeight; j++) { + for (i = 0; i < chWidth; i ++) { + if (*(pBmp + j * byteWidth + i / 8) & (128 >> (i & 7))) + SSD1306_pixel(oled, x + i, y + j, 1); + } + } +} + +void SSD1306_display(ssd1306 *oled) +{ + command(oled, SSD1306_COLUMNADDR); + command(oled, 0); /* cloumn start address */ + command(oled, width - 1); /*cloumn end address */ + command(oled, SSD1306_PAGEADDR); + command(oled, 0); /* page atart address */ + command(oled, pages - 1); /* page end address */ + + libsoc_gpio_set_level(oled->dc, HIGH); + /* TODO: get the correct size of buf */ + libsoc_spi_write(oled->spi_dev, oled->buffer, sizeof(oled->buffer)); +} diff --git a/ssd1306/ssd1306.h b/ssd1306/ssd1306.h new file mode 100644 index 0000000..415b75b --- /dev/null +++ b/ssd1306/ssd1306.h @@ -0,0 +1,387 @@ +#ifndef _SSD1306_SPI_H_ +#define _SSD1306_SPI_H_ + +#include +#include +#include +#include "libsoc_gpio.h" +#include "libsoc_spi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + gpio *res, *dc; + spi *spi_dev; + unsigned char buffer[1024]; + bool switch_capvcc; +} ssd1306; + +#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_COLUMNADDR 0x21 +#define SSD1306_PAGEADDR 0x22 +#define SSD1306_COMSCANINC 0xC0 +#define SSD1306_COMSCANDEC 0xC8 +#define SSD1306_SEGREMAP 0xA0 +#define SSD1306_CHARGEPUMP 0x8D +#define SSD1306_EXTERNALVCC 0x01 +#define SSD1306_SWITCHCAPVCC 0x02 + +/* Scrolling constants */ +#define SSD1306_ACTIVATE_SCROLL 0x2F +#define SSD1306_DEACTIVATE_SCROLL 0x2E +#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 +#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 +#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 +#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 +#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A + +void SSD1306_begin(ssd1306 *oled); +void SSD1306_display(ssd1306 *oled); +void SSD1306_clear(ssd1306 *oled); +void SSD1306_pixel(ssd1306 *oled, int x,int y,char color); +void SSD1306_bitmap(ssd1306 *oled, unsigned char x,unsigned char y,const unsigned char *pBmp,char chWidth,char chHeight); +void SSD1306_string(ssd1306 *oled, uint8_t x, uint8_t y, const char *pString, uint8_t Size, uint8_t Mode); +void SSD1306_char1616(ssd1306 *oled, uint8_t x, uint8_t y, uint8_t chChar); +void SSD1306_char3216(ssd1306 *oled, uint8_t x, uint8_t y, uint8_t chChar); + +static const uint8_t Font1206[95][12] = { + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/ + {0x00,0x00,0x00,0x00,0x3F,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/ + {0x00,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x40,0x00,0x00,0x00},/*""",2*/ + {0x09,0x00,0x0B,0xC0,0x3D,0x00,0x0B,0xC0,0x3D,0x00,0x09,0x00},/*"#",3*/ + {0x18,0xC0,0x24,0x40,0x7F,0xE0,0x22,0x40,0x31,0x80,0x00,0x00},/*"$",4*/ + {0x18,0x00,0x24,0xC0,0x1B,0x00,0x0D,0x80,0x32,0x40,0x01,0x80},/*"%",5*/ + {0x03,0x80,0x1C,0x40,0x27,0x40,0x1C,0x80,0x07,0x40,0x00,0x40},/*"&",6*/ + {0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/ + {0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x20,0x40,0x40,0x20},/*"(",8*/ + {0x00,0x00,0x40,0x20,0x20,0x40,0x1F,0x80,0x00,0x00,0x00,0x00},/*")",9*/ + {0x09,0x00,0x06,0x00,0x1F,0x80,0x06,0x00,0x09,0x00,0x00,0x00},/*"*",10*/ + {0x04,0x00,0x04,0x00,0x3F,0x80,0x04,0x00,0x04,0x00,0x00,0x00},/*"+",11*/ + {0x00,0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/ + {0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00},/*"-",13*/ + {0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/ + {0x00,0x20,0x01,0xC0,0x06,0x00,0x38,0x00,0x40,0x00,0x00,0x00},/*"/",15*/ + {0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"0",16*/ + {0x00,0x00,0x10,0x40,0x3F,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"1",17*/ + {0x18,0xC0,0x21,0x40,0x22,0x40,0x24,0x40,0x18,0x40,0x00,0x00},/*"2",18*/ + {0x10,0x80,0x20,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"3",19*/ + {0x02,0x00,0x0D,0x00,0x11,0x00,0x3F,0xC0,0x01,0x40,0x00,0x00},/*"4",20*/ + {0x3C,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x23,0x80,0x00,0x00},/*"5",21*/ + {0x1F,0x80,0x24,0x40,0x24,0x40,0x34,0x40,0x03,0x80,0x00,0x00},/*"6",22*/ + {0x30,0x00,0x20,0x00,0x27,0xC0,0x38,0x00,0x20,0x00,0x00,0x00},/*"7",23*/ + {0x1B,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"8",24*/ + {0x1C,0x00,0x22,0xC0,0x22,0x40,0x22,0x40,0x1F,0x80,0x00,0x00},/*"9",25*/ + {0x00,0x00,0x00,0x00,0x08,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/ + {0x00,0x00,0x00,0x00,0x04,0x60,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/ + {0x00,0x00,0x04,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0x40,0x40},/*"<",28*/ + {0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x00,0x00},/*"=",29*/ + {0x00,0x00,0x40,0x40,0x20,0x80,0x11,0x00,0x0A,0x00,0x04,0x00},/*">",30*/ + {0x18,0x00,0x20,0x00,0x23,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"?",31*/ + {0x1F,0x80,0x20,0x40,0x27,0x40,0x29,0x40,0x1F,0x40,0x00,0x00},/*"@",32*/ + {0x00,0x40,0x07,0xC0,0x39,0x00,0x0F,0x00,0x01,0xC0,0x00,0x40},/*"A",33*/ + {0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"B",34*/ + {0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x30,0x80,0x00,0x00},/*"C",35*/ + {0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"D",36*/ + {0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x40,0x30,0xC0,0x00,0x00},/*"E",37*/ + {0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x00,0x30,0x00,0x00,0x00},/*"F",38*/ + {0x0F,0x00,0x10,0x80,0x20,0x40,0x22,0x40,0x33,0x80,0x02,0x00},/*"G",39*/ + {0x20,0x40,0x3F,0xC0,0x04,0x00,0x04,0x00,0x3F,0xC0,0x20,0x40},/*"H",40*/ + {0x20,0x40,0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x00,0x00},/*"I",41*/ + {0x00,0x60,0x20,0x20,0x20,0x20,0x3F,0xC0,0x20,0x00,0x20,0x00},/*"J",42*/ + {0x20,0x40,0x3F,0xC0,0x24,0x40,0x0B,0x00,0x30,0xC0,0x20,0x40},/*"K",43*/ + {0x20,0x40,0x3F,0xC0,0x20,0x40,0x00,0x40,0x00,0x40,0x00,0xC0},/*"L",44*/ + {0x3F,0xC0,0x3C,0x00,0x03,0xC0,0x3C,0x00,0x3F,0xC0,0x00,0x00},/*"M",45*/ + {0x20,0x40,0x3F,0xC0,0x0C,0x40,0x23,0x00,0x3F,0xC0,0x20,0x00},/*"N",46*/ + {0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"O",47*/ + {0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"P",48*/ + {0x1F,0x80,0x21,0x40,0x21,0x40,0x20,0xE0,0x1F,0xA0,0x00,0x00},/*"Q",49*/ + {0x20,0x40,0x3F,0xC0,0x24,0x40,0x26,0x00,0x19,0xC0,0x00,0x40},/*"R",50*/ + {0x18,0xC0,0x24,0x40,0x24,0x40,0x22,0x40,0x31,0x80,0x00,0x00},/*"S",51*/ + {0x30,0x00,0x20,0x40,0x3F,0xC0,0x20,0x40,0x30,0x00,0x00,0x00},/*"T",52*/ + {0x20,0x00,0x3F,0x80,0x00,0x40,0x00,0x40,0x3F,0x80,0x20,0x00},/*"U",53*/ + {0x20,0x00,0x3E,0x00,0x01,0xC0,0x07,0x00,0x38,0x00,0x20,0x00},/*"V",54*/ + {0x38,0x00,0x07,0xC0,0x3C,0x00,0x07,0xC0,0x38,0x00,0x00,0x00},/*"W",55*/ + {0x20,0x40,0x39,0xC0,0x06,0x00,0x39,0xC0,0x20,0x40,0x00,0x00},/*"X",56*/ + {0x20,0x00,0x38,0x40,0x07,0xC0,0x38,0x40,0x20,0x00,0x00,0x00},/*"Y",57*/ + {0x30,0x40,0x21,0xC0,0x26,0x40,0x38,0x40,0x20,0xC0,0x00,0x00},/*"Z",58*/ + {0x00,0x00,0x00,0x00,0x7F,0xE0,0x40,0x20,0x40,0x20,0x00,0x00},/*"[",59*/ + {0x00,0x00,0x70,0x00,0x0C,0x00,0x03,0x80,0x00,0x40,0x00,0x00},/*"\",60*/ + {0x00,0x00,0x40,0x20,0x40,0x20,0x7F,0xE0,0x00,0x00,0x00,0x00},/*"]",61*/ + {0x00,0x00,0x20,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00},/*"^",62*/ + {0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10},/*"_",63*/ + {0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/ + {0x00,0x00,0x02,0x80,0x05,0x40,0x05,0x40,0x03,0xC0,0x00,0x40},/*"a",65*/ + {0x20,0x00,0x3F,0xC0,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"b",66*/ + {0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x06,0x40,0x00,0x00},/*"c",67*/ + {0x00,0x00,0x03,0x80,0x04,0x40,0x24,0x40,0x3F,0xC0,0x00,0x40},/*"d",68*/ + {0x00,0x00,0x03,0x80,0x05,0x40,0x05,0x40,0x03,0x40,0x00,0x00},/*"e",69*/ + {0x00,0x00,0x04,0x40,0x1F,0xC0,0x24,0x40,0x24,0x40,0x20,0x00},/*"f",70*/ + {0x00,0x00,0x02,0xE0,0x05,0x50,0x05,0x50,0x06,0x50,0x04,0x20},/*"g",71*/ + {0x20,0x40,0x3F,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"h",72*/ + {0x00,0x00,0x04,0x40,0x27,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"i",73*/ + {0x00,0x10,0x00,0x10,0x04,0x10,0x27,0xE0,0x00,0x00,0x00,0x00},/*"j",74*/ + {0x20,0x40,0x3F,0xC0,0x01,0x40,0x07,0x00,0x04,0xC0,0x04,0x40},/*"k",75*/ + {0x20,0x40,0x20,0x40,0x3F,0xC0,0x00,0x40,0x00,0x40,0x00,0x00},/*"l",76*/ + {0x07,0xC0,0x04,0x00,0x07,0xC0,0x04,0x00,0x03,0xC0,0x00,0x00},/*"m",77*/ + {0x04,0x40,0x07,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"n",78*/ + {0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"o",79*/ + {0x04,0x10,0x07,0xF0,0x04,0x50,0x04,0x40,0x03,0x80,0x00,0x00},/*"p",80*/ + {0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x50,0x07,0xF0,0x00,0x10},/*"q",81*/ + {0x04,0x40,0x07,0xC0,0x02,0x40,0x04,0x00,0x04,0x00,0x00,0x00},/*"r",82*/ + {0x00,0x00,0x06,0x40,0x05,0x40,0x05,0x40,0x04,0xC0,0x00,0x00},/*"s",83*/ + {0x00,0x00,0x04,0x00,0x1F,0x80,0x04,0x40,0x00,0x40,0x00,0x00},/*"t",84*/ + {0x04,0x00,0x07,0x80,0x00,0x40,0x04,0x40,0x07,0xC0,0x00,0x40},/*"u",85*/ + {0x04,0x00,0x07,0x00,0x04,0xC0,0x01,0x80,0x06,0x00,0x04,0x00},/*"v",86*/ + {0x06,0x00,0x01,0xC0,0x07,0x00,0x01,0xC0,0x06,0x00,0x00,0x00},/*"w",87*/ + {0x04,0x40,0x06,0xC0,0x01,0x00,0x06,0xC0,0x04,0x40,0x00,0x00},/*"x",88*/ + {0x04,0x10,0x07,0x10,0x04,0xE0,0x01,0x80,0x06,0x00,0x04,0x00},/*"y",89*/ + {0x00,0x00,0x04,0x40,0x05,0xC0,0x06,0x40,0x04,0x40,0x00,0x00},/*"z",90*/ + {0x00,0x00,0x00,0x00,0x04,0x00,0x7B,0xE0,0x40,0x20,0x00,0x00},/*"{",91*/ + {0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00},/*"|",92*/ + {0x00,0x00,0x40,0x20,0x7B,0xE0,0x04,0x00,0x00,0x00,0x00,0x00},/*"}",93*/ + {0x40,0x00,0x80,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0x40,0x00},/*"~",94*/ +}; + +static const uint8_t Font1608[95][16] = { + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/ + {0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xCC,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/ + {0x00,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x00,0x00},/*""",2*/ + {0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x00,0x00},/*"#",3*/ + {0x00,0x00,0x0E,0x18,0x11,0x04,0x3F,0xFF,0x10,0x84,0x0C,0x78,0x00,0x00,0x00,0x00},/*"$",4*/ + {0x0F,0x00,0x10,0x84,0x0F,0x38,0x00,0xC0,0x07,0x78,0x18,0x84,0x00,0x78,0x00,0x00},/*"%",5*/ + {0x00,0x78,0x0F,0x84,0x10,0xC4,0x11,0x24,0x0E,0x98,0x00,0xE4,0x00,0x84,0x00,0x08},/*"&",6*/ + {0x08,0x00,0x68,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/ + {0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x18,0x18,0x20,0x04,0x40,0x02,0x00,0x00},/*"(",8*/ + {0x00,0x00,0x40,0x02,0x20,0x04,0x18,0x18,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00},/*")",9*/ + {0x02,0x40,0x02,0x40,0x01,0x80,0x0F,0xF0,0x01,0x80,0x02,0x40,0x02,0x40,0x00,0x00},/*"*",10*/ + {0x00,0x80,0x00,0x80,0x00,0x80,0x0F,0xF8,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00},/*"+",11*/ + {0x00,0x01,0x00,0x0D,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/ + {0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80},/*"-",13*/ + {0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/ + {0x00,0x00,0x00,0x06,0x00,0x18,0x00,0x60,0x01,0x80,0x06,0x00,0x18,0x00,0x20,0x00},/*"/",15*/ + {0x00,0x00,0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"0",16*/ + {0x00,0x00,0x08,0x04,0x08,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"1",17*/ + {0x00,0x00,0x0E,0x0C,0x10,0x14,0x10,0x24,0x10,0x44,0x11,0x84,0x0E,0x0C,0x00,0x00},/*"2",18*/ + {0x00,0x00,0x0C,0x18,0x10,0x04,0x11,0x04,0x11,0x04,0x12,0x88,0x0C,0x70,0x00,0x00},/*"3",19*/ + {0x00,0x00,0x00,0xE0,0x03,0x20,0x04,0x24,0x08,0x24,0x1F,0xFC,0x00,0x24,0x00,0x00},/*"4",20*/ + {0x00,0x00,0x1F,0x98,0x10,0x84,0x11,0x04,0x11,0x04,0x10,0x88,0x10,0x70,0x00,0x00},/*"5",21*/ + {0x00,0x00,0x07,0xF0,0x08,0x88,0x11,0x04,0x11,0x04,0x18,0x88,0x00,0x70,0x00,0x00},/*"6",22*/ + {0x00,0x00,0x1C,0x00,0x10,0x00,0x10,0xFC,0x13,0x00,0x1C,0x00,0x10,0x00,0x00,0x00},/*"7",23*/ + {0x00,0x00,0x0E,0x38,0x11,0x44,0x10,0x84,0x10,0x84,0x11,0x44,0x0E,0x38,0x00,0x00},/*"8",24*/ + {0x00,0x00,0x07,0x00,0x08,0x8C,0x10,0x44,0x10,0x44,0x08,0x88,0x07,0xF0,0x00,0x00},/*"9",25*/ + {0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/ + {0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/ + {0x00,0x00,0x00,0x80,0x01,0x40,0x02,0x20,0x04,0x10,0x08,0x08,0x10,0x04,0x00,0x00},/*"<",28*/ + {0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x00,0x00},/*"=",29*/ + {0x00,0x00,0x10,0x04,0x08,0x08,0x04,0x10,0x02,0x20,0x01,0x40,0x00,0x80,0x00,0x00},/*">",30*/ + {0x00,0x00,0x0E,0x00,0x12,0x00,0x10,0x0C,0x10,0x6C,0x10,0x80,0x0F,0x00,0x00,0x00},/*"?",31*/ + {0x03,0xE0,0x0C,0x18,0x13,0xE4,0x14,0x24,0x17,0xC4,0x08,0x28,0x07,0xD0,0x00,0x00},/*"@",32*/ + {0x00,0x04,0x00,0x3C,0x03,0xC4,0x1C,0x40,0x07,0x40,0x00,0xE4,0x00,0x1C,0x00,0x04},/*"A",33*/ + {0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x11,0x04,0x0E,0x88,0x00,0x70,0x00,0x00},/*"B",34*/ + {0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x08,0x1C,0x10,0x00,0x00},/*"C",35*/ + {0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"D",36*/ + {0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x17,0xC4,0x10,0x04,0x08,0x18,0x00,0x00},/*"E",37*/ + {0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x17,0xC0,0x10,0x00,0x08,0x00,0x00,0x00},/*"F",38*/ + {0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x44,0x1C,0x78,0x00,0x40,0x00,0x00},/*"G",39*/ + {0x10,0x04,0x1F,0xFC,0x10,0x84,0x00,0x80,0x00,0x80,0x10,0x84,0x1F,0xFC,0x10,0x04},/*"H",40*/ + {0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x00,0x00,0x00,0x00},/*"I",41*/ + {0x00,0x03,0x00,0x01,0x10,0x01,0x10,0x01,0x1F,0xFE,0x10,0x00,0x10,0x00,0x00,0x00},/*"J",42*/ + {0x10,0x04,0x1F,0xFC,0x11,0x04,0x03,0x80,0x14,0x64,0x18,0x1C,0x10,0x04,0x00,0x00},/*"K",43*/ + {0x10,0x04,0x1F,0xFC,0x10,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x0C,0x00,0x00},/*"L",44*/ + {0x10,0x04,0x1F,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x1F,0xFC,0x10,0x04,0x00,0x00},/*"M",45*/ + {0x10,0x04,0x1F,0xFC,0x0C,0x04,0x03,0x00,0x00,0xE0,0x10,0x18,0x1F,0xFC,0x10,0x00},/*"N",46*/ + {0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"O",47*/ + {0x10,0x04,0x1F,0xFC,0x10,0x84,0x10,0x80,0x10,0x80,0x10,0x80,0x0F,0x00,0x00,0x00},/*"P",48*/ + {0x07,0xF0,0x08,0x18,0x10,0x24,0x10,0x24,0x10,0x1C,0x08,0x0A,0x07,0xF2,0x00,0x00},/*"Q",49*/ + {0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x11,0xC0,0x11,0x30,0x0E,0x0C,0x00,0x04},/*"R",50*/ + {0x00,0x00,0x0E,0x1C,0x11,0x04,0x10,0x84,0x10,0x84,0x10,0x44,0x1C,0x38,0x00,0x00},/*"S",51*/ + {0x18,0x00,0x10,0x00,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x00,0x18,0x00,0x00,0x00},/*"T",52*/ + {0x10,0x00,0x1F,0xF8,0x10,0x04,0x00,0x04,0x00,0x04,0x10,0x04,0x1F,0xF8,0x10,0x00},/*"U",53*/ + {0x10,0x00,0x1E,0x00,0x11,0xE0,0x00,0x1C,0x00,0x70,0x13,0x80,0x1C,0x00,0x10,0x00},/*"V",54*/ + {0x1F,0xC0,0x10,0x3C,0x00,0xE0,0x1F,0x00,0x00,0xE0,0x10,0x3C,0x1F,0xC0,0x00,0x00},/*"W",55*/ + {0x10,0x04,0x18,0x0C,0x16,0x34,0x01,0xC0,0x01,0xC0,0x16,0x34,0x18,0x0C,0x10,0x04},/*"X",56*/ + {0x10,0x00,0x1C,0x00,0x13,0x04,0x00,0xFC,0x13,0x04,0x1C,0x00,0x10,0x00,0x00,0x00},/*"Y",57*/ + {0x08,0x04,0x10,0x1C,0x10,0x64,0x10,0x84,0x13,0x04,0x1C,0x04,0x10,0x18,0x00,0x00},/*"Z",58*/ + {0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x40,0x02,0x40,0x02,0x40,0x02,0x00,0x00},/*"[",59*/ + {0x00,0x00,0x30,0x00,0x0C,0x00,0x03,0x80,0x00,0x60,0x00,0x1C,0x00,0x03,0x00,0x00},/*"\",60*/ + {0x00,0x00,0x40,0x02,0x40,0x02,0x40,0x02,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00},/*"]",61*/ + {0x00,0x00,0x00,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00},/*"^",62*/ + {0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01},/*"_",63*/ + {0x00,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/ + {0x00,0x00,0x00,0x98,0x01,0x24,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xFC,0x00,0x04},/*"a",65*/ + {0x10,0x00,0x1F,0xFC,0x00,0x88,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"b",66*/ + {0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x00},/*"c",67*/ + {0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x11,0x08,0x1F,0xFC,0x00,0x04},/*"d",68*/ + {0x00,0x00,0x00,0xF8,0x01,0x44,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xC8,0x00,0x00},/*"e",69*/ + {0x00,0x00,0x01,0x04,0x01,0x04,0x0F,0xFC,0x11,0x04,0x11,0x04,0x11,0x00,0x18,0x00},/*"f",70*/ + {0x00,0x00,0x00,0xD6,0x01,0x29,0x01,0x29,0x01,0x29,0x01,0xC9,0x01,0x06,0x00,0x00},/*"g",71*/ + {0x10,0x04,0x1F,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"h",72*/ + {0x00,0x00,0x01,0x04,0x19,0x04,0x19,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"i",73*/ + {0x00,0x00,0x00,0x03,0x00,0x01,0x01,0x01,0x19,0x01,0x19,0xFE,0x00,0x00,0x00,0x00},/*"j",74*/ + {0x10,0x04,0x1F,0xFC,0x00,0x24,0x00,0x40,0x01,0xB4,0x01,0x0C,0x01,0x04,0x00,0x00},/*"k",75*/ + {0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"l",76*/ + {0x01,0x04,0x01,0xFC,0x01,0x04,0x01,0x00,0x01,0xFC,0x01,0x04,0x01,0x00,0x00,0xFC},/*"m",77*/ + {0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"n",78*/ + {0x00,0x00,0x00,0xF8,0x01,0x04,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0xF8,0x00,0x00},/*"o",79*/ + {0x01,0x01,0x01,0xFF,0x00,0x85,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"p",80*/ + {0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x05,0x01,0xFF,0x00,0x01},/*"q",81*/ + {0x01,0x04,0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x04,0x01,0x00,0x01,0x80,0x00,0x00},/*"r",82*/ + {0x00,0x00,0x00,0xCC,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x98,0x00,0x00},/*"s",83*/ + {0x00,0x00,0x01,0x00,0x01,0x00,0x07,0xF8,0x01,0x04,0x01,0x04,0x00,0x00,0x00,0x00},/*"t",84*/ + {0x01,0x00,0x01,0xF8,0x00,0x04,0x00,0x04,0x00,0x04,0x01,0x08,0x01,0xFC,0x00,0x04},/*"u",85*/ + {0x01,0x00,0x01,0x80,0x01,0x70,0x00,0x0C,0x00,0x10,0x01,0x60,0x01,0x80,0x01,0x00},/*"v",86*/ + {0x01,0xF0,0x01,0x0C,0x00,0x30,0x01,0xC0,0x00,0x30,0x01,0x0C,0x01,0xF0,0x01,0x00},/*"w",87*/ + {0x00,0x00,0x01,0x04,0x01,0x8C,0x00,0x74,0x01,0x70,0x01,0x8C,0x01,0x04,0x00,0x00},/*"x",88*/ + {0x01,0x01,0x01,0x81,0x01,0x71,0x00,0x0E,0x00,0x18,0x01,0x60,0x01,0x80,0x01,0x00},/*"y",89*/ + {0x00,0x00,0x01,0x84,0x01,0x0C,0x01,0x34,0x01,0x44,0x01,0x84,0x01,0x0C,0x00,0x00},/*"z",90*/ + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x3E,0xFC,0x40,0x02,0x40,0x02},/*"{",91*/ + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00},/*"|",92*/ + {0x00,0x00,0x40,0x02,0x40,0x02,0x3E,0xFC,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"}",93*/ + {0x00,0x00,0x60,0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x20,0x00},/*"~",94*/ +}; + +static const uint8_t Font1612[11][32] = +{ + {0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C, + 0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"0",0*/ + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00, + 0x30,0x00,0x3F,0xFC,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"1",1*/ + {0x00,0x00,0x39,0xFC,0x39,0xFC,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C, + 0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0x8C,0x3F,0x8C,0x00,0x00},/*"2",2*/ + {0x00,0x00,0x38,0x1C,0x38,0x1C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C, + 0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"3",3*/ + {0x00,0x00,0x3F,0x80,0x3F,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80, + 0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"4",4*/ + {0x00,0x00,0x3F,0xBC,0x3F,0xBC,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C, + 0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0xFC,0x31,0xFC,0x00,0x00},/*"5",5*/ + {0x00,0x00,0x3F,0x9C,0x3F,0x9C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C, + 0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0xFC,0x31,0xFC,0x00,0x00},/*"6",6*/ + {0x00,0x00,0x38,0x00,0x38,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00, + 0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"7",7*/ + {0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C, + 0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"8",8*/ + {0x00,0x00,0x3F,0x9C,0x3F,0x9C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C, + 0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"9",9*/ + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x30, + 0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*":",10*/ +}; + +static const uint8_t Font3216[11][64] = +{ + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC, /*"0",0*/ + 0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C, + 0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C, + 0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*"1",1*/ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00, + 0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,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,0x3C,0x01,0xFF,0xFC,0x3C,0x01,0xFF,0xFC, /*"2",2*/ + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x3F,0xFF,0x80,0x0C,0x3F,0xFF,0x80,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x3C,0x38,0x00,0x00,0x3C, /*"3",3*/ + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x00,0x3F,0xFF,0x80,0x00, /*"4",4*/ + 0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00, + 0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00, + 0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x3C,0x3F,0xFF,0x80,0x3C, /*"5",5*/ + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x30,0x01,0xFF,0xFC,0x30,0x01,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC, /*"6",6*/ + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x3C,0x01,0xFF,0xFC,0x3C,0x01,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x3C,0x00,0x00,0x00, /*"7",7*/ + 0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00, + 0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00, + 0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC, /*"8",8*/ + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x3C,0x3F,0xFF,0x80,0x3C, /*"9",9*/ + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C, + 0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*":",10*/ + 0x00,0x00,0x00,0x00,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x0C,0x00,0x00,0x30, + 0x0C,0x00,0x00,0x30,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} +}; + +static const uint8_t Bmp4016[96] = /* SUN */ +{ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF1,0x81,0x8F,0xFC,0x3F, + 0xF1,0x81,0x8F,0xFC,0x30,0x31,0x81,0x8C,0x0C,0x30,0x01,0x81,0x8C,0x0C,0x30,0x01, + 0x81,0x8C,0x0C,0x3F,0xF1,0x81,0x8C,0x0C,0x3F,0xF1,0x81,0x8C,0x0C,0x00,0x31,0x81, + 0x8C,0x0C,0x00,0x31,0x81,0x8C,0x0C,0x30,0x31,0x81,0x8C,0x0C,0x3F,0xF1,0xFF,0x8C, + 0x0C,0x3F,0xF1,0xFF,0x8C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; + +static const uint8_t Singal816[16] = /* mobie singal */ +{ + 0xFE,0x02,0x92,0x0A,0x54,0x2A,0x38,0xAA,0x12,0xAA,0x12,0xAA,0x12,0xAA,0x12,0xAA +}; + +static const uint8_t Msg816[16] = /* message */ +{ + 0x1F,0xF8,0x10,0x08,0x18,0x18,0x14,0x28,0x13,0xC8,0x10,0x08,0x10,0x08,0x1F,0xF8 +}; + +static const uint8_t Bat816[16] = /* batery */ +{ + 0x0F,0xFE,0x30,0x02,0x26,0xDA,0x26,0xDA,0x26,0xDA,0x26,0xDA,0x30,0x02,0x0F,0xFE +}; + +static const uint8_t Bluetooth88[8] = /* bluetooth */ +{ + 0x18,0x54,0x32,0x1C,0x1C,0x32,0x54,0x18 +}; + +static const uint8_t GPRS88[8] = /* GPRS */ +{ + 0xC3,0x99,0x24,0x20,0x2C,0x24,0x99,0xC3 +}; + +static const uint8_t Alarm88[8] = /* alram */ +{ + 0xC3,0xBD,0x42,0x52,0x4E,0x42,0x3C,0xC3 +}; + +#ifdef __cplusplus +} +#endif +#endif