ZumoPolytech / Mbed 2 deprecated EcranZumo

Dependencies:   mbed SSD1306

Revision:
1:a9b0228da2a0
Parent:
0:15f95f9cf61a
Child:
2:a6904bea0678
--- a/main.cpp	Sun May 04 14:31:18 2014 +0000
+++ b/main.cpp	Fri Feb 15 17:33:35 2019 +0000
@@ -8,80 +8,229 @@
 #include "standard_font.h"
 #include "bold_font.h"
 
-// SSD1306 oled(p8 /* cs */, p9 /* reset */, p14 /* dc */, p13 /* clock */, p11 /* data */); // LPC1768
+ SSD1306 oled(p8 /* cs */, p9 /* reset */, p10 /* dc */, p7 /* clock */, p5 /* data */); // LPC1768
 // SSD1306 oled(PTA13 /* cs */, PTD5 /* reset */, PTD0 /* dc */, PTD1 /* clock */, PTD2 /* data */); // KL25Z
-SSD1306 oled(D10 /* cs */, D9 /* reset */, D8 /* dc */, D13 /* clock */, D11 /* data */); // KL05Z or Arduino styles
+//SSD1306 oled(D10 /* cs */, D9 /* reset */, D8 /* dc */, D13 /* clock */, D11 /* data */); // KL05Z or Arduino styles
 
 #define NUMFLAKES 10
 #define XPOS 0
 #define YPOS 1
 #define DELTAY 2
 
-#define LOGO16_GLCD_HEIGHT 16 
-#define LOGO16_GLCD_WIDTH  16 
-static const unsigned char  logo16_glcd_bmp[] =
-{ 0x00, 0xc0, // B00000000, B11000000,
-  0x01, 0xc0, // B00000001, B11000000,
-  0x01, 0xc0, // B00000001, B11000000,
-  0x03, 0xe0, // B00000011, B11100000,
-  0xf3, 0xe0, // B11110011, B11100000,
-  0xfe, 0xf8, // B11111110, B11111000,
-  0x7e, 0xff, // B01111110, B11111111,
-  0x33, 0x9f, // B00110011, B10011111,
-  0x1f, 0xfc, // B00011111, B11111100,
-  0x0d, 0x70, // B00001101, B01110000,
-  0x1b, 0xa0, // B00011011, B10100000,
-  0x3f, 0xe0, // B00111111, B11100000,
-  0x3f, 0xf0, // B00111111, B11110000,
-  0x7c, 0xf0, // B01111100, B11110000,
-  0x70, 0x70, // B01110000, B01110000,
-  0x00, 0x30 }; // B00000000, B00110000 };
-
-void testdrawbitmap(const unsigned char *bitmap, int w, int h) {
-  uint8_t icons[NUMFLAKES][3];
-  srand((unsigned int)time(NULL)); // srandom(666);     // whatever seed
-  int i;
+#define LOGO16_GLCD_HEIGHT 48 
+#define LOGO16_GLCD_WIDTH  48 
+static const unsigned char  logo64_glcd_bmp[] =
+{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x00,0x00,0x00,0x3f,0xfc,0x00,0x00,0x00
+,0x00,0x00,0x01,0xff,0xff,0x80,0x00,0x00
+,0x00,0x00,0x0f,0x80,0x01,0xf0,0x00,0x00
+,0x00,0x00,0x3c,0x00,0x00,0x78,0x00,0x00
+,0x00,0x00,0x70,0x00,0x00,0x0e,0x00,0x00
+,0x00,0x01,0xe0,0x00,0x00,0x07,0x00,0x00
+,0x00,0x03,0x80,0x00,0x00,0x01,0xc0,0x00
+,0x00,0x07,0x00,0x00,0x00,0x00,0xe0,0x00
+,0x00,0x0e,0x00,0x00,0x00,0x00,0x70,0x00
+,0x00,0x1c,0x00,0x00,0x00,0x00,0x38,0x00
+,0x00,0x38,0x00,0x00,0x00,0x00,0x18,0x00
+,0x00,0x30,0x00,0x00,0x00,0x00,0x0c,0x00
+,0x00,0x60,0x00,0x00,0x00,0x00,0x06,0x00
+,0x00,0xc0,0x00,0x00,0x00,0x00,0x06,0x00
+,0x00,0xc0,0x00,0x00,0x00,0x00,0x03,0x00
+,0x01,0x80,0x00,0x00,0x00,0x00,0x01,0x80
+,0x01,0x80,0x00,0x00,0x00,0x00,0x01,0x80
+,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xc0
+,0x03,0x00,0x0c,0x00,0x00,0x20,0x00,0xc0
+,0x06,0x00,0x3f,0x00,0x01,0xfc,0x00,0x40
+,0x06,0x00,0x73,0x80,0x03,0x8e,0x00,0x60
+,0x06,0x00,0xc0,0xc0,0x03,0x06,0x00,0x60
+,0x04,0x00,0xc0,0xc0,0x06,0x02,0x00,0x20
+,0x0c,0x00,0xc0,0x40,0x06,0x02,0x00,0x30
+,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x30
+,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x30
+,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x30
+,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x30
+,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x10
+,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x10
+,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x10
+,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x10
+,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x10
+,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x10
+,0x08,0x00,0x60,0x00,0x00,0x04,0x00,0x30
+,0x0c,0x00,0x60,0x00,0x00,0x04,0x00,0x30
+,0x0c,0x00,0x60,0x00,0x00,0x04,0x00,0x30
+,0x0c,0x00,0x20,0x00,0x00,0x04,0x00,0x30
+,0x0c,0x00,0x30,0x00,0x00,0x0c,0x00,0x20
+,0x04,0x00,0x30,0x00,0x00,0x0c,0x00,0x60
+,0x06,0x00,0x30,0x00,0x00,0x08,0x00,0x60
+,0x06,0x00,0x18,0x00,0x00,0x18,0x00,0x60
+,0x02,0x00,0x18,0x00,0x00,0x18,0x00,0xc0
+,0x03,0x00,0x0c,0x00,0x00,0x30,0x00,0xc0
+,0x03,0x00,0x0e,0x00,0x00,0x60,0x00,0x80
+,0x01,0x80,0x07,0x00,0x00,0xe0,0x01,0x80
+,0x01,0x80,0x03,0x80,0x01,0xc0,0x03,0x00
+,0x00,0xc0,0x01,0xe0,0x07,0x80,0x03,0x00
+,0x00,0x60,0x00,0x78,0x3e,0x00,0x06,0x00
+,0x00,0x60,0x00,0x1f,0xf8,0x00,0x0e,0x00
+,0x00,0x30,0x00,0x03,0xc0,0x00,0x0c,0x00
+,0x00,0x18,0x00,0x00,0x00,0x00,0x18,0x00
+,0x00,0x0c,0x00,0x00,0x00,0x00,0x30,0x00
+,0x00,0x06,0x00,0x00,0x00,0x00,0x60,0x00
+,0x00,0x03,0x00,0x00,0x00,0x00,0xc0,0x00
+,0x00,0x01,0xc0,0x00,0x00,0x03,0x80,0x00
+,0x00,0x00,0xe0,0x00,0x00,0x07,0x00,0x00
+,0x00,0x00,0x78,0x00,0x00,0x1e,0x00,0x00
+,0x00,0x00,0x1e,0x00,0x00,0x78,0x00,0x00
+,0x00,0x00,0x07,0xe0,0x07,0xe0,0x00,0x00
+,0x00,0x00,0x01,0xff,0xff,0x00,0x00,0x00
+,0x00,0x00,0x00,0x1f,0xf8,0x00,0x00,0x00
+,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ };
+ 
+  static const unsigned char  logoeye_bmp[] ={
+ 0x00,0x00,0x00,0x80,0x00,0x00,0x00
+,0x00,0x00,0x10,0x81,0x00,0x00,0x00
+,0x00,0x04,0x10,0x81,0x04,0x00,0x00
+,0x00,0x04,0x10,0x81,0x04,0x10,0x00
+,0x00,0x84,0x10,0x81,0x04,0x30,0x00
+,0x00,0x86,0x10,0x83,0x0c,0x30,0x00
+,0x00,0x82,0x10,0xc2,0x08,0x20,0x00
+,0x20,0xc2,0x18,0xc2,0x18,0x60,0x80
+,0x30,0xc3,0x18,0xc2,0x18,0x40,0x80
+,0x10,0x61,0x18,0x02,0x10,0xc1,0x80
+,0x18,0x61,0x10,0x00,0x10,0xc1,0x00
+,0x08,0x21,0x07,0xfc,0x00,0x83,0x00
+,0x0c,0x30,0xfc,0x07,0xe0,0x86,0x00
+,0x06,0x03,0xe1,0xf0,0xfc,0x0c,0x00
+,0x03,0x1e,0x0f,0x0e,0x0f,0x08,0x00
+,0x00,0x78,0x18,0x03,0x01,0xc0,0x00
+,0x00,0xe0,0x18,0x01,0x00,0xe0,0x00
+,0x01,0xc0,0x30,0x01,0x80,0x30,0x00
+,0x03,0x00,0x20,0xf0,0x80,0x1c,0x00
+,0x06,0x00,0x21,0xf0,0x80,0x0e,0x00
+,0x0c,0x00,0x23,0xf8,0xc0,0x03,0x00
+,0x0c,0x00,0x23,0xf8,0xc0,0x03,0x00
+,0x0e,0x00,0x21,0xf8,0xc0,0x06,0x00
+,0x07,0x00,0x20,0xf0,0x80,0x0c,0x00
+,0x01,0x80,0x30,0x00,0x80,0x38,0x00
+,0x00,0xe0,0x10,0x01,0x80,0x60,0x00
+,0x00,0x78,0x0c,0x03,0x01,0xc0,0x00
+,0x00,0x3c,0x0c,0x06,0x07,0x80,0x00
+,0x00,0x07,0xc3,0xf8,0x3e,0x00,0x00
+,0x00,0x01,0xf8,0x01,0xf0,0x00,0x00
+,0x00,0x00,0x1f,0xff,0x00,0x00,0x00
+,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
  
-  // initialize
-  for (uint8_t f=0; f< NUMFLAKES; f++) {
-    icons[f][XPOS] = rand() % SSD1306_LCDWIDTH; // display.width();
-    icons[f][YPOS] = 0;
-    icons[f][DELTAY] = rand() % 5 + 1;
-#if 0
-    Serial.print("x: ");
-    Serial.print(icons[f][XPOS], DEC);
-    Serial.print(" y: ");
-    Serial.print(icons[f][YPOS], DEC);
-    Serial.print(" dy: ");
-    Serial.println(icons[f][DELTAY], DEC);
-#endif
-  }
+ static const unsigned char  logopops_bmp[] =
+{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x00,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x00,0xff,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x03,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x07,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x0f,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x1f,0xff,0xff,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x3f,0xff,0xff,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x3f,0xc0,0x3f,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x7f,0x80,0x1f,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0xff,0x00,0x0f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0xfe,0x00,0x07,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0xfc,0x00,0x03,0xf0,0x38,0x3c,0x20,0x8c,0xf8,0xf0,0xf0,0x88
+,0x00,0x00,0x03,0xf0,0x3c,0x7e,0x20,0xcc,0xf8,0xf8,0xf8,0xcc
+,0x00,0x00,0x03,0xf0,0x26,0x66,0x20,0x48,0x30,0xc1,0x98,0xcc
+,0x00,0x00,0x03,0xf0,0x3c,0x66,0x20,0x70,0x20,0xf1,0x98,0xfc
+,0x00,0x00,0x03,0xf0,0x38,0x7e,0x3c,0x30,0x20,0xf1,0xf8,0xcc
+,0xfc,0x00,0x03,0xf0,0x20,0x3c,0x3c,0x30,0x20,0xf0,0xf0,0x88
+,0xfe,0x00,0x07,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0xff,0x00,0x0f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0xff,0x00,0x0f,0xe0,0x31,0x19,0x30,0xe5,0x30,0x00,0x00,0x00
+,0xff,0xc0,0x3f,0xe0,0x2a,0x95,0x40,0x85,0x28,0x00,0x00,0x00
+,0xff,0xf0,0x7f,0xc0,0x3a,0x9d,0x30,0xe5,0x2c,0x00,0x00,0x00
+,0xff,0xff,0xff,0xc0,0x23,0x95,0x08,0x25,0x2c,0x00,0x00,0x00
+,0xff,0xff,0xff,0x80,0x22,0x95,0x30,0xe7,0x38,0x00,0x00,0x00
+,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0xfc,0xff,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x7c,0x3f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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
+};
 
-  i = 0;
-  while (1) {
-    // draw each icon
-    for (uint8_t f=0; f< NUMFLAKES; f++) {
-      oled.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, 1); // WHITE);
-    }
-    oled.update();
-    wait(0.2); // delay(200);
-    
-    // then erase it + move it
-    for (uint8_t f=0; f< NUMFLAKES; f++) {
-      oled.drawBitmap(icons[f][XPOS], icons[f][YPOS],  logo16_glcd_bmp, w, h, 0); // BLACK);
-      // move it
-      icons[f][YPOS] += icons[f][DELTAY];
-      // if its gone, reinit
-      if (icons[f][YPOS] > SSD1306_LCDHEIGHT) { // display.height()) {
-        icons[f][XPOS] = rand() % SSD1306_LCDWIDTH; // display.width();
-        icons[f][YPOS] = 0;
-        icons[f][DELTAY] = rand() % 5 + 1;
-      }
-    }
-    if (i++ > 100) break;
-   }
+ static const unsigned char  logoclose_bmp[] ={
+0x00,0x00,0x3f,0xfe,0x00,0x00,0x00
+,0x00,0x03,0xe0,0x07,0xe0,0x00,0x00
+,0x00,0x1f,0x00,0x00,0xf8,0x00,0x00
+,0x00,0x78,0x00,0x00,0x0f,0x00,0x00
+,0x00,0xe0,0x00,0x00,0x07,0x80,0x00
+,0x01,0x80,0x00,0x00,0x01,0xc0,0x00
+,0x07,0x00,0x00,0x00,0x00,0x60,0x00
+,0x0c,0x00,0x00,0x00,0x00,0x38,0x00
+,0x18,0x00,0x00,0x00,0x00,0x1c,0x00
+,0x30,0x00,0x00,0x00,0x00,0x0c,0x00
+,0x30,0x00,0x00,0x00,0x00,0x0c,0x00
+,0x1c,0x00,0x00,0x00,0x00,0x18,0x00
+,0x0e,0x00,0x00,0x00,0x00,0x30,0x00
+,0x03,0x00,0x00,0x00,0x00,0xe0,0x00
+,0x01,0xc0,0x00,0x00,0x01,0xc0,0x00
+,0x03,0xe0,0x00,0x00,0x07,0xe0,0x00
+,0x07,0xfc,0x00,0x00,0x1f,0xf0,0x00
+,0x06,0x7c,0x00,0x00,0x1e,0x30,0x00
+,0x0c,0x6f,0xc0,0x01,0xf3,0x18,0x00
+,0x18,0x43,0xf8,0x0f,0xe3,0x0c,0x00
+,0x30,0x42,0x1f,0xfe,0x21,0x04,0x00
+,0x20,0xc2,0x18,0xc2,0x21,0x86,0x00
+,0x60,0xc2,0x10,0xc6,0x21,0x82,0x00
+,0x40,0x86,0x10,0xc6,0x30,0xc3,0x00
+,0x41,0x86,0x10,0xc6,0x10,0xc1,0x00
+,0x01,0x04,0x10,0xc2,0x10,0x40,0x00
+,0x03,0x0c,0x30,0x43,0x18,0x40,0x00
+,0x03,0x08,0x20,0x43,0x08,0x40,0x00
+,0x02,0x08,0x20,0x41,0x08,0x00,0x00
+,0x00,0x08,0x20,0x41,0x08,0x00,0x00
+,0x00,0x00,0x20,0x41,0x00,0x00,0x00
+,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
 
-}
+ static const unsigned char  oeil_bmp[] ={
+0x0e,0x00,0x1f,0x00,0x3f,0x80,0x71,0xc0
+,0x64,0xc0,0x7f,0xc0,0x7f,0xc0,0x3f,0x80
+,0x1f,0x00,0x0e,0x00,0x00,0x00
+};
+
+ static const unsigned char  oeilvide_bmp[] ={
+0x00,0x00,0x00,0x80,0x00,0x00,0x00
+,0x00,0x00,0x10,0x81,0x00,0x00,0x00
+,0x00,0x04,0x10,0x81,0x04,0x00,0x00
+,0x00,0x04,0x10,0x81,0x04,0x10,0x00
+,0x00,0x84,0x10,0x81,0x04,0x30,0x00
+,0x00,0x86,0x10,0x83,0x0c,0x30,0x00
+,0x00,0x82,0x10,0xc2,0x08,0x20,0x00
+,0x20,0xc2,0x18,0xc2,0x18,0x60,0x80
+,0x30,0xc3,0x18,0xc2,0x18,0x40,0x80
+,0x10,0x61,0x18,0x02,0x10,0xc1,0x80
+,0x18,0x61,0x10,0x00,0x10,0xc1,0x00
+,0x08,0x21,0x07,0xfc,0x00,0x83,0x00
+,0x0c,0x30,0xfc,0x07,0xe0,0x86,0x00
+,0x06,0x03,0xc0,0x00,0x7c,0x0c,0x00
+,0x03,0x1e,0x00,0x00,0x0f,0x08,0x00
+,0x00,0x78,0x00,0x00,0x01,0xc0,0x00
+,0x00,0xe0,0x00,0x00,0x00,0xe0,0x00
+,0x01,0xc0,0x00,0x00,0x00,0x30,0x00
+,0x03,0x00,0x00,0x00,0x00,0x1c,0x00
+,0x06,0x00,0x00,0x00,0x00,0x0e,0x00
+,0x0c,0x00,0x00,0x00,0x00,0x03,0x00
+,0x0c,0x00,0x00,0x00,0x00,0x03,0x00
+,0x0e,0x00,0x00,0x00,0x00,0x06,0x00
+,0x07,0x00,0x00,0x00,0x00,0x0c,0x00
+,0x01,0x80,0x00,0x00,0x00,0x38,0x00
+,0x00,0xe0,0x00,0x00,0x00,0x60,0x00
+,0x00,0x78,0x00,0x00,0x01,0xc0,0x00
+,0x00,0x3c,0x00,0x00,0x07,0x80,0x00
+,0x00,0x07,0xc0,0x00,0x3e,0x00,0x00
+,0x00,0x01,0xf8,0x01,0xf0,0x00,0x00
+,0x00,0x00,0x1f,0xff,0x00,0x00,0x00
+,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
 
 void testdrawline() {  
   for (int16_t i=0; i<SSD1306_LCDWIDTH; i+=4) {
@@ -134,34 +283,41 @@
     oled.clear();
     oled.set_contrast(255); // max contrast
     
-    oled.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16);
+    oled.drawBitmap(32, 0,  logo64_glcd_bmp, 64, 64);
     oled.update();
     wait(3);
-    
-    testdrawline();
+    int j=1;
+    int jd,jg;
     
-    oled.clear();
-    testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
-
-    oled.set_font(bold_font, 8);
-    oled.printf("Heading\r\n");
-
-    oled.set_font(standard_font, 6);
-    oled.printf("Hello World!\r\n");
-    oled.printf("Some more text here...\r\n\r\n\r\n\r\n");
-    // oled.set_font(bold_font, 8);
-    oled.line(127, 0, 0, 63);
-
-    oled.update();
-    wait(1);
-
+while(1){    
+    for(int i=0;i<(128);i=i+j){
+            //oled.drawBitmap(i,0,  logo2_bmp, 94, 32);
+            jg= ((i<=11) ? 11 : (i>=28 ? 28 : i));
+            jd=  ((i<=(11+127-50)) ? (11+127-50): (i>=(28+127-50) ? (28+127-50) : i));
+            oled.drawBitmap(0,0,oeilvide_bmp, 50, 32);
+            oled.drawBitmap(127-50,0,oeilvide_bmp, 50, 32);
+            oled.drawBitmap(jg,15,oeil_bmp, 11, 11);
+            oled.drawBitmap(jd,15,oeil_bmp, 11, 11);
+            
+/*          if(jj>0) {
+                oled.drawBitmap(0,0,  logoeye_bmp, 50, 32);
+                oled.drawBitmap(127-50,0,  logoeye_bmp, 50, 32);
+            }else{
+                oled.drawBitmap(0,0,  logoclose_bmp, 50, 32);
+                oled.drawBitmap(127-50,0,  logoclose_bmp, 50, 32);
+            }
+*/             
+            oled.drawBitmap(i,32,  logopops_bmp, 94, 32);
+            oled.update();
+            wait(0.01); 
+            oled.clear();
+            j=((i==127)||((j==-1)&&(i==0)) ? -j : j);
+    }
+}
     int i = 0;
-    while (1)
-    {
-        wait(1);
-        oled.printf("%d\r\n", i++);
-        oled.update();
-        oled.scroll_up();
+   
+    while (1) {
+   
     }
 }