[242] | 1 | #include <Wire.h>
|
---|
| 2 | #include <SeeedOLED.h>
|
---|
| 3 | #include <avr/pgmspace.h>
|
---|
| 4 |
|
---|
| 5 | static unsigned char SeeedLogo[] PROGMEM ={
|
---|
| 6 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
|
---|
| 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 9 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 11 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 12 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 14 | 0x60, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
|
---|
| 15 | 0xff, 0xfc, 0x00, 0x00, 0x00, 0x80, 0xf0, 0x20, 0x00, 0x00, 0x80, 0xc0, 0xc0, 0x60, 0xe0, 0xc0,
|
---|
| 16 | 0xc0, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x60, 0xe0, 0xc0, 0xc0, 0x80, 0x00, 0x00, 0x80, 0xc0,
|
---|
| 17 | 0xc0, 0xe0, 0x60, 0xc0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x60, 0xe0, 0xc0, 0xc0,
|
---|
| 18 | 0x80, 0x00, 0x00, 0x80, 0xc0, 0xc0, 0xe0, 0xe0, 0xc0, 0xc0, 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00,
|
---|
| 19 | 0x00, 0xc0, 0xc0, 0xe0, 0x60, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xf0, 0xf0, 0xf0, 0xc0, 0x00, 0xc0,
|
---|
| 20 | 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0xc0, 0xe0, 0xe0, 0xc0, 0xc0,
|
---|
| 21 | 0xf8, 0xf8, 0x00, 0xd8, 0xd8, 0x00, 0x00, 0x80, 0xc0, 0xc0, 0xe0, 0x60, 0xc0, 0xc0, 0x80, 0x00,
|
---|
| 22 | 0x00, 0x03, 0x0f, 0x1e, 0x3c, 0x70, 0xe3, 0xcf, 0x9f, 0x30, 0x00, 0x00, 0x00, 0x00, 0x70, 0xbf,
|
---|
| 23 | 0xcf, 0xe3, 0x70, 0x78, 0x3e, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x33, 0x77, 0x66, 0x66, 0x66, 0x6c,
|
---|
| 24 | 0x7d, 0x18, 0x00, 0x1f, 0x3f, 0x76, 0x66, 0x66, 0x66, 0x76, 0x37, 0x07, 0x00, 0x0f, 0x3f, 0x7f,
|
---|
| 25 | 0x66, 0x66, 0x66, 0x66, 0x77, 0x27, 0x07, 0x00, 0x1f, 0x3f, 0x76, 0x66, 0x66, 0x66, 0x76, 0x37,
|
---|
| 26 | 0x07, 0x00, 0x0f, 0x3f, 0x71, 0x60, 0x60, 0x60, 0x60, 0x31, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00,
|
---|
| 27 | 0x11, 0x37, 0x67, 0x66, 0x66, 0x6c, 0x7d, 0x38, 0x00, 0x00, 0x3f, 0x7f, 0x3f, 0x00, 0x00, 0x1f,
|
---|
| 28 | 0x3f, 0x70, 0x60, 0x60, 0x70, 0x7f, 0x7f, 0x00, 0x0f, 0x3f, 0x71, 0x60, 0x60, 0x60, 0x60, 0x31,
|
---|
| 29 | 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x06, 0x1f, 0x3b, 0x60, 0x60, 0x60, 0x60, 0x71, 0x3f, 0x1f,
|
---|
| 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
---|
| 31 | 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 35 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x48, 0x48, 0x48, 0xb0, 0x00, 0xc0, 0x20,
|
---|
| 39 | 0x20, 0x20, 0xc0, 0x00, 0xc0, 0x20, 0x20, 0x20, 0xc0, 0x00, 0x40, 0xa0, 0xa0, 0xa0, 0x20, 0x00,
|
---|
| 40 | 0x00, 0x20, 0xf0, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0xf8, 0x08,
|
---|
| 41 | 0x08, 0x00, 0xc0, 0x20, 0x20, 0x20, 0xf8, 0x00, 0xc0, 0xa0, 0xa0, 0xa0, 0xc0, 0x00, 0x20, 0xa0,
|
---|
| 42 | 0xa0, 0xa0, 0xc0, 0x00, 0x40, 0xa0, 0xa0, 0xa0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x48, 0x48, 0x48, 0x08, 0x00, 0x20, 0x40, 0x80, 0x40,
|
---|
| 44 | 0x20, 0x00, 0x00, 0x20, 0xf0, 0x20, 0x20, 0x00, 0xc0, 0xa0, 0xa0, 0xa0, 0xc0, 0x00, 0xe0, 0x00,
|
---|
| 45 | 0x20, 0x20, 0xc0, 0x00, 0xc0, 0x20, 0x20, 0x20, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02,
|
---|
| 47 | 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00,
|
---|
| 48 | 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x03, 0x02,
|
---|
| 49 | 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02,
|
---|
| 50 | 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x08, 0x06, 0x00, 0x00, 0x00,
|
---|
| 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x82, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01,
|
---|
| 52 | 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x03, 0x00,
|
---|
| 53 | 0x00, 0x00, 0x03, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 54 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 56 | 0x00, 0x00, 0x00, 0x82, 0x8c, 0x60, 0x1c, 0x02, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x1c, 0x00, 0x1e,
|
---|
| 57 | 0x20, 0x20, 0x00, 0x3e, 0x00, 0x00, 0x3e, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 58 | 0x00, 0x00, 0x3e, 0x04, 0x02, 0x02, 0x00, 0x1c, 0x2a, 0x2a, 0x2a, 0x0c, 0x00, 0x12, 0x2a, 0x2a,
|
---|
| 59 | 0x2a, 0x1c, 0x20, 0x1c, 0x22, 0x22, 0x22, 0x14, 0x00, 0x3f, 0x00, 0x02, 0x02, 0x3c, 0x00, 0x00,
|
---|
| 60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 65 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 66 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 67 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
| 69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
---|
| 70 | };
|
---|
| 71 |
|
---|
| 72 | void setup()
|
---|
| 73 | {
|
---|
| 74 | Wire.begin();
|
---|
| 75 | SeeedOled.init(); //initialze SEEED OLED display
|
---|
| 76 | DDRB|=0x21;
|
---|
| 77 | PORTB |= 0x21;
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | void setDisplayToOriginalState(char testCase)
|
---|
| 83 |
|
---|
| 84 | {
|
---|
| 85 | delay(5000);
|
---|
| 86 | SeeedOled.init(); //initialze SEEED OLED display
|
---|
| 87 | SeeedOled.clearDisplay(); // clear the screen and set start position to top left corner
|
---|
| 88 | SeeedOled.deactivateScroll(); // deactivete Scroll (might be activated by previous test case)
|
---|
| 89 | SeeedOled.setNormalDisplay(); // Non-inverted Display
|
---|
| 90 | SeeedOled.setPageMode(); // Page mode to start with
|
---|
| 91 | SeeedOled.setTextXY(2,0); // 0 Page, 0th Column
|
---|
| 92 | SeeedOled.putString("Test Case ");
|
---|
| 93 | SeeedOled.putNumber(testCase);
|
---|
| 94 | SeeedOled.setTextXY(3,0);
|
---|
| 95 | SeeedOled.putString("Test Case ");
|
---|
| 96 | SeeedOled.putNumber(testCase);
|
---|
| 97 | SeeedOled.setTextXY(4,0);
|
---|
| 98 | SeeedOled.putString("Test Case ");
|
---|
| 99 | SeeedOled.putNumber(testCase);
|
---|
| 100 | SeeedOled.setTextXY(5,0);
|
---|
| 101 | SeeedOled.putString("Test Case ");
|
---|
| 102 | SeeedOled.putNumber(testCase);
|
---|
| 103 | delay(2000);
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 | void loop()
|
---|
| 111 | {
|
---|
| 112 |
|
---|
| 113 | setDisplayToOriginalState(1);
|
---|
| 114 |
|
---|
| 115 | SeeedOled.clearDisplay(); //clear the screen and set start position to top left corner
|
---|
| 116 | SeeedOled.setNormalDisplay(); //Set display to normal mode (i.e non-inverse mode)
|
---|
| 117 | SeeedOled.setPageMode(); //Set addressing mode to Page Mode
|
---|
| 118 | SeeedOled.setTextXY(0,0); //Set the cursor to Xth Page, Yth Column
|
---|
| 119 | SeeedOled.putString("Hello World!"); //Print the String
|
---|
| 120 |
|
---|
| 121 |
|
---|
| 122 | setDisplayToOriginalState(2);
|
---|
| 123 |
|
---|
| 124 | SeeedOled.clearDisplay(); //clear the screen and set start position to top left corner
|
---|
| 125 | SeeedOled.setNormalDisplay(); //Set display to Normal mode
|
---|
| 126 | SeeedOled.setPageMode(); //Set addressing mode to Page Mode
|
---|
| 127 | SeeedOled.setTextXY(0,0); //Set the cursor to 0th Page, 0th Column
|
---|
| 128 | SeeedOled.putNumber(123); //Print number
|
---|
| 129 | SeeedOled.setTextXY(1,0); //Set the cursor to 1st Page, 0th Column
|
---|
| 130 | SeeedOled.putNumber(0xFFFF); //Print number
|
---|
| 131 | SeeedOled.setTextXY(2,0); //Set the cursor to 2nd Page, 0th Column
|
---|
| 132 | SeeedOled.putNumber(0xFFFFFFFF); //Print number
|
---|
| 133 | SeeedOled.setTextXY(3,0); //Set the cursor to 3rd Page, 0th Column
|
---|
| 134 | SeeedOled.putNumber(-12345); //Print number
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | setDisplayToOriginalState(3);
|
---|
| 138 |
|
---|
| 139 | SeeedOled.clearDisplay(); //clear the screen and set start position to top left corner
|
---|
| 140 | SeeedOled.setNormalDisplay(); //Set display to Normal mode
|
---|
| 141 | SeeedOled.setHorizontalMode(); //Set addressing mode to Horizontal Mode
|
---|
| 142 | SeeedOled.putString("!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); //Print String (ASCII 32 - 126 )
|
---|
| 143 |
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | setDisplayToOriginalState(4);
|
---|
| 147 |
|
---|
| 148 | SeeedOled.clearDisplay(); // clear the screen and set start position to top left corner
|
---|
| 149 | SeeedOled.drawBitmap(SeeedLogo,1024); // 1024 = 128 Pixels * 64 Pixels / 8
|
---|
| 150 |
|
---|
| 151 | setDisplayToOriginalState(5);
|
---|
| 152 |
|
---|
| 153 | SeeedOled.setInverseDisplay(); // Set Display to inverse mode
|
---|
| 154 | SeeedOled.clearDisplay(); // clear the screen and set start position to top left corner
|
---|
| 155 | SeeedOled.drawBitmap(SeeedLogo,1024); // 1024 = 128 Pixels * 64 Pixels / 8
|
---|
| 156 |
|
---|
| 157 | setDisplayToOriginalState(6);
|
---|
| 158 |
|
---|
| 159 | SeeedOled.clearDisplay(); // clear the screen and set start position to top left corner
|
---|
| 160 | SeeedOled.drawBitmap(SeeedLogo,1024); // 1024 = 128 Pixels * 64 Pixels / 8
|
---|
| 161 | SeeedOled.setHorizontalScrollProperties(Scroll_Left,4,7,Scroll_5Frames); //Set Scrolling properties to Scroll Left
|
---|
| 162 | SeeedOled.activateScroll(); // Activate Scrolling
|
---|
| 163 | delay(5000);
|
---|
| 164 |
|
---|
| 165 | setDisplayToOriginalState(7);
|
---|
| 166 |
|
---|
| 167 | SeeedOled.clearDisplay(); // clear the screen and set start position to top left corner
|
---|
| 168 | SeeedOled.drawBitmap(SeeedLogo,1024); // 1024 = 128 Pixels * 64 Pixels / 8
|
---|
| 169 | SeeedOled.setHorizontalScrollProperties(Scroll_Right,4,7,Scroll_5Frames); //Set the properties of Horizontal Scrool
|
---|
| 170 | SeeedOled.activateScroll(); // Activate Scroll
|
---|
| 171 | delay(5000);
|
---|
| 172 |
|
---|
| 173 |
|
---|
| 174 | }
|
---|
| 175 |
|
---|