tom 发表于 2013-8-3 08:07:10

张老师Microduino-OLED12864显示器图片移动的问题

本帖最后由 tom 于 2013-8-6 23:25 编辑

张老师Microduino-OLED12864显示器图片移动的问题
本显示器驱动芯片是SSD1306
显示器如何连接,和显示字符串看另一个贴子http://www.geek-workshop.com/thread-5483-1-1.html

图片显示参阅我的另一篇贴子http://www.geek-workshop.com/thread-5527-1-1.html

本例中的图是一个256*64图片,宽度是12864的两倍,高度与屏幕相同。


void movePictureToRight(void)
图片从左向右移动,图片的第一点开始位置于屏幕的最右边(128,0),当它到达最左边时坐标(-128,0)
它的坐标轴X表达式=128-i*10,而它的Y轴坐标不变,为了能显示它Y轴坐标-25。即Y轴表达式=-25

0=-256+i*10=> i=25.6
程序表达式    display.drawBitmap( 128-i*10, -25, logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT, 1);

本程序段完整表达为
void movePictureToRight(void)

{
//由于str2.bmp图片尺寸是256=2*128
//向左边移动,它的左边尺寸应该是X=128,高度选0
//每次显示图片后,清屏,在它的左边减少10个像素,就能实现图片向左移动
//移动变量定义为int i
//每次移动10个像素,只需要26次就足够了256/10=25.6


for (int i=0;i<=26;i++)
{


    display.drawBitmap( 128-i*10, -25, logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT, 1);
    //在指定的位置绘出图形

    display.display();//在12864液晶屏中显示出来   
    delay(50);
    display.clearDisplay();//清屏
}

}

至于其它的程序段与此类似,不再累述。(详见程序)

Arduino 完整的代码如下:
*
* // # Update the Adafruit SSD1306 library to make it work
* // # Description:
* // #                 show a simple animation
*
* // # Connection:
* // #      SCL-> A5(Uno)/D3(Leonardo)
* // #      SDA-> A4(Uno)/D2(Leonardo)
* // #      RST-> D4
* // #      DC-> GND
* // #      3.3-> 3.3v
* // #      g-> GND
* // #
*
*
*
* This example is for a 128x64 size display using I2C to communicate
* 3 pins are required to interface (2 I2C and one reset)
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
* BSD license, check license.txt for more information
* All text above, and the splash screen must be included in any redistribution
*********************************************************************/

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
SSD1306 display(OLED_RESET);

#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
//本程序在IDE V1.01调试通过

#define LOGO16_GLCD_HEIGHT 64 //图片高度
#define LOGO16_GLCD_WIDTH256 //图片宽度
static unsigned char PROGMEM logo16_glcd_bmp[] =
{
//本图片是汉字: 欢迎来到 极客工坊论坛
/*--宽度x高度=256x64--*/
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,
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,
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,
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,
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,
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,
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,
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,0x10,0x00,0x04,0x00,0x0C,0x00,0x00,0x04,0x00,0x03,0x00,0x00,
0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x0C,0x00,0x0C,0x00,0x07,0x04,0x00,0x03,0x00,0x00,
0x08,0x00,0x00,0x00,0x08,0x30,0x00,0x08,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x30,0x06,0x18,0x00,0x0F,0x80,0x3E,0x04,0x00,0x03,0x03,0x81,
0x1F,0xE0,0x00,0x00,0x08,0x18,0x06,0x18,0x00,0x81,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x20,0x03,0x31,0xC0,0x7C,0x00,0x08,0x24,0x00,0x03,0x3D,0x81,
0xE0,0x60,0x01,0xE0,0x08,0x00,0x03,0x1C,0x00,0x8F,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0x2F,0x00,0x66,0x60,0x0C,0xC0,0x1A,0x24,0x00,0x03,0x99,0x03,
0x10,0x80,0x3F,0x00,0x08,0x07,0x80,0x36,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x33,0x72,0x00,0x22,0x60,0x6D,0x80,0x13,0x24,0x00,0x1F,0x1B,0x02,
0x3E,0x00,0x03,0x00,0x0E,0xFE,0x00,0x23,0x00,0xE0,0x30,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x84,0x07,0x22,0x40,0x2C,0x00,0x7D,0x24,0x00,0x03,0x12,0x00,
0x46,0x00,0x03,0x00,0x38,0x10,0x00,0x61,0xC3,0x83,0xF8,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x12,0x30,0x0D,0x2B,0xC0,0x0F,0xE0,0x48,0x24,0x00,0x03,0x17,0x00,
0xAC,0x00,0x03,0x00,0x08,0x30,0x0E,0x40,0xF0,0xBE,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0A,0x30,0x02,0x32,0xC1,0xFC,0x00,0x0E,0x24,0x00,0x06,0xB1,0x00,
0x18,0x00,0x02,0x00,0x08,0x3E,0x3A,0x93,0x00,0x82,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x04,0x30,0x02,0x62,0x00,0x1A,0x00,0x3C,0x24,0x00,0x0A,0x2B,0x00,
0x37,0x00,0x02,0x00,0x0E,0x46,0x02,0x16,0x00,0xA6,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x28,0x03,0x02,0x00,0x39,0x80,0x08,0x24,0x00,0x12,0x2A,0x00,
0x61,0xC0,0x02,0x00,0x18,0xC4,0x04,0x1C,0x00,0xC4,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x09,0x6C,0x01,0x02,0x00,0x68,0xE0,0x0F,0x84,0x00,0x02,0x46,0x01,
0xCF,0x78,0x03,0xFC,0x71,0x8C,0x04,0x90,0x81,0x88,0x40,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x10,0x46,0x0F,0xF2,0x00,0xC8,0x7E,0xFC,0x04,0x00,0x02,0x89,0x86,
0x7B,0x00,0xFE,0x00,0x03,0x08,0x07,0x10,0x87,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x20,0x83,0x00,0x1F,0xFB,0x08,0x00,0x60,0x14,0x00,0x02,0x30,0xE0,
0x42,0x00,0x00,0x00,0x06,0x38,0x06,0x1F,0xC0,0x10,0x20,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x01,0xC0,0x03,0xE0,0x08,0x00,0x00,0x0C,0x00,0x02,0x00,0x00,
0x7E,0x00,0x00,0x00,0x00,0x30,0x04,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x0C,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,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,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,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,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,

};

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

void setup()   {               
Serial.begin(9600);

display.begin(SSD1306_SWITCHCAPVCC, 0x3c);// initialize with the I2C addr 0x3C (for the 128x64)
// init done
//初始化12864屏幕






}

void movePictureToRight(void)

{
//由于str2.bmp图片尺寸是256=2*128
//向左边移动,它的左边尺寸应该是X=128,高度选0
//每次显示图片后,清屏,在它的左边减少10个像素,就能实现图片向左移动
//移动变量定义为int i
//每次移动10个像素,只需要26次就足够了256/10=25.6


for (int i=0;i<=26;i++)
{


    display.drawBitmap( 128-i*10, -25, logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT, 1);
    //在指定的位置绘出图形

    display.display();//在12864液晶屏中显示出来   
    delay(50);
    display.clearDisplay();//清屏
}

}

void   movePictureToLeft(void)
{

for (int i=0;i<=26;i++)
{

    display.clearDisplay();//清屏
    display.drawBitmap( -256+i*10, -25, logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT, 1);
    //在指定的位置绘出图形

    display.display();//在12864液晶屏中显示出来   
    delay(100);

}

}   

void   movePictureToUp(void)
{

for (int i=0;i<=7;i++)
{
    for (int j=0;j<=26;j++)
    {
      display.clearDisplay();//清屏
      display.drawBitmap( 0-j*10, 64-i*10, logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT, 1);
      //在指定的位置绘出图形

      display.display();//在12864液晶屏中显示出来   
      delay(100);
    }

}
}

void   movePictureToDown(void)
{

for (int i=0;i<=7;i++)
{
    for (int j=0;j<=26;j++)
    {
      display.clearDisplay();//清屏
      display.drawBitmap( 0-j*10, -64+i*10, logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT, 1);
      //在指定的位置绘出图形

      display.display();//在12864液晶屏中显示出来   
      delay(100);
    }
}
}
uint8_t draw_state = 0;

void mydraw(void) {

switch(draw_state >> 3) {
case 0:
    movePictureToLeft();
    break;
case 1:   
    movePictureToRight() ;
    break;
case 2:
    movePictureToUp();
    break;
case 3:
    movePictureToDown();
    break;



}
}

void loop() {
mydraw();

draw_state++;
if ( draw_state >= 7*8 )
    draw_state = 0;
}



页: [1]
查看完整版本: 张老师Microduino-OLED12864显示器图片移动的问题