Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheCodeArtist/d36ab2d7eb1f04aacc34 to your computer and use it in GitHub Desktop.
Save TheCodeArtist/d36ab2d7eb1f04aacc34 to your computer and use it in GitHub Desktop.
Bitmap and Triangles demo on 0.96" I2C 128x64 OLED display connected to Arduino UNO
/*
* Bitmap and Shatterring-glass demo on 0.96" I2C 128x64 OLED display connected to Arduino UNO
*
* Demo Video: https://youtu.be/El5VYXpw27I
*
* Author: TheCodeartist (cvs268@gmail.com) 2015
* Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
* http://creativecommons.org/licenses/by-sa/4.0/
*
*
* Uses u8glib - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
* Copyright (c) 2012, 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.
*/
// Select the proper pin to which the buzzer is connected.
const uint8_t soundPin = 8;
/**************************************************
* Public Constants for sounds derived from
* http://www.arduino.cc/en/Tutorial/Tone
*************************************************/
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_A3 220
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978
// A simple melody with 8 notes...
int melody[] = {
NOTE_A4, NOTE_C4, NOTE_D4, NOTE_C4, 0, NOTE_C3, NOTE_A3, 0
};
// ...and the durations of each corresponding note above.
int noteDurations[] = {
4, 4, 8, 4, 0, 8, 4, 4
};
void playMelody() {
// melody tempo linked to frame-rate.
static uint8_t callCounter = 0;
static uint8_t thisNote = 0;
// Each melody has 8 notes, each note is played for 16 calls to draw().
// Each demo has 16 frames, each frame comprises of 8 calls to draw().
// Effectively each melody plays for exactly 1 iteration of a demo.
// There are 4 instances of demos in each iteration of main activity loop.
if ((callCounter++ & 0xf) == 0) {
// stop the currently playing tone to preapre for next tone.
noTone(soundPin);
uint16_t noteDuration = 1000 / noteDurations[thisNote];
tone(soundPin, melody[thisNote], noteDuration);
thisNote++;
// if completed playing entire melody, repeat it again.
if (thisNote > 7) {
thisNote = 0;
}
}
}
#include "U8glib.h"
// Fast I2C/TWI
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST);
const uint8_t nvidia_bitmap_dark[] PROGMEM = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0xff,0xff,0xfe,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x07,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x03,0xf8,0x00,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x1f,0xe7,0xc0,0x3f,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x7e,0x07,0xf8,0x0f,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0xf8,0x07,0xfe,0x07,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x03,0xf0,0x00,0x7f,0x01,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x07,0xc0,0x78,0x0f,0xc0,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x1f,0x81,0xf8,0x03,0xe0,0x7f,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x3f,0x07,0xe0,0x01,0xf0,0x3f,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x7e,0x0f,0x87,0x00,0xf8,0x1f,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x7c,0x1f,0x07,0x80,0xf8,0x3f,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x7e,0x1e,0x07,0xc3,0xf0,0x7f,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x3e,0x1e,0x07,0xe7,0xe0,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x3f,0x0f,0x07,0xef,0xc1,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x1f,0x0f,0x07,0xff,0x83,0xfb,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x0f,0x87,0x87,0xff,0x07,0xf0,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x0f,0x83,0xc7,0xfc,0x0f,0xc0,0x3f,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x07,0xc1,0xe7,0xf8,0x3f,0x80,0x1f,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x03,0xe0,0xfb,0xc0,0x7f,0x00,0x1f,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x01,0xf0,0x78,0x01,0xfc,0x00,0x7f,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0xf8,0x08,0x0f,0xf8,0x00,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x7e,0x07,0xff,0xe0,0x03,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x3f,0x07,0xff,0x00,0x1f,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x0f,0xe7,0xf8,0x00,0x7f,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x07,0xf8,0x00,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0x3f,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x07,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x1f,0xf8,0x3c,0x0f,0x3c,0x7f,0x80,0xe0,0x1f,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x1f,0xfe,0x3c,0x0f,0x3c,0xff,0xe0,0xf0,0x3f,0x80,0x00,0x00,0x00
,0x00,0x00,0x00,0x1f,0xff,0x3c,0x0f,0x3c,0xff,0xf0,0xf0,0x3f,0x80,0x00,0x00,0x00
,0x00,0x00,0x00,0x1f,0xff,0x1e,0x1e,0x3c,0xf0,0xf8,0xf0,0x3f,0x80,0x00,0x00,0x00
,0x00,0x00,0x00,0x1e,0x0f,0x9e,0x1e,0x3c,0xf0,0x78,0xf0,0x7b,0xc0,0x00,0x00,0x00
,0x00,0x00,0x00,0x1e,0x07,0x9e,0x1e,0x3c,0xf0,0x3c,0xf0,0x73,0xc0,0x00,0x00,0x00
,0x00,0x00,0x00,0x1e,0x07,0x8f,0x3c,0x3c,0xf0,0x3c,0xf0,0xf1,0xe0,0x00,0x00,0x00
,0x00,0x00,0x00,0x1e,0x07,0x8f,0x3c,0x3c,0xf0,0x3c,0xf0,0xf1,0xe0,0x00,0x00,0x00
,0x00,0x00,0x00,0x1e,0x07,0x8f,0x3c,0x3c,0xf0,0x3c,0xf0,0xe0,0xe0,0x00,0x00,0x00
,0x00,0x00,0x00,0x1e,0x07,0x87,0x38,0x3c,0xf0,0x3c,0xf1,0xff,0xf0,0x00,0x00,0x00
,0x00,0x00,0x00,0x1e,0x07,0x87,0xf8,0x3c,0xf0,0x78,0xf1,0xff,0xf0,0x00,0x00,0x00
,0x00,0x00,0x00,0x1e,0x07,0x87,0xf8,0x3c,0xff,0xf8,0xf3,0xff,0xf8,0x00,0x00,0x00
,0x00,0x00,0x00,0x1e,0x07,0x87,0xf0,0x3c,0xff,0xf0,0xf3,0xc0,0x78,0x00,0x00,0x00
,0x00,0x00,0x00,0x1e,0x07,0x83,0xf0,0x3c,0xff,0xe0,0xf3,0x80,0x78,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
const uint8_t nvidia_bitmap_bright[] PROGMEM = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x00,0x00,0x01,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0xf8,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xf8,0x07,0xff,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xe0,0x18,0x3f,0xc0,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0x80,0xf8,0x07,0xf0,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0x07,0xf8,0x01,0xf8,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xfc,0x0f,0xff,0x00,0x7e,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xf8,0x3f,0x87,0xf0,0x3f,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xe0,0x7e,0x07,0xfc,0x1f,0x80,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xc0,0xf8,0x1b,0xfe,0x0f,0xc0,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0x81,0xf0,0x78,0xff,0x07,0xe0,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0x83,0xe0,0xf8,0x7f,0x07,0xc0,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0x81,0xe1,0xf8,0x3c,0x0f,0x80,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xc1,0xe1,0xf8,0x18,0x1f,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xc0,0xf0,0xf8,0x10,0x3e,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xe0,0xf0,0x78,0x00,0x7c,0x04,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xf0,0x78,0x78,0x00,0xf8,0x0f,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xf0,0x3c,0x38,0x03,0xf0,0x3f,0xc0,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xf8,0x3e,0x08,0x07,0xc0,0x7f,0xe0,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xfc,0x1f,0x00,0x3f,0x80,0xff,0xe0,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xfe,0x0f,0x87,0xfe,0x03,0xff,0x80,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0x07,0xe7,0xf0,0x07,0xff,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0x81,0xf8,0x00,0x1f,0xfc,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xc0,0xf8,0x00,0xff,0xe0,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xe0,0x18,0x07,0xff,0x80,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xf8,0x07,0xff,0xfc,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0xff,0xc0,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xf8,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xe0,0x07,0xc3,0xf0,0xc3,0x00,0x7f,0x0f,0xe0,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xe0,0x01,0xc3,0xf0,0xc3,0x00,0x0f,0x0f,0xc0,0x7f,0xff,0xff,0xff
,0xff,0xff,0xff,0xe0,0x00,0xc3,0xf0,0xc3,0x00,0x07,0x0f,0xc0,0x7f,0xff,0xff,0xff
,0xff,0xff,0xff,0xe0,0x00,0xe1,0xe1,0xc3,0x06,0x07,0x0f,0xc0,0x7f,0xff,0xff,0xff
,0xff,0xff,0xff,0xe1,0xf0,0x61,0xe1,0xc3,0x0f,0x83,0x0f,0x84,0x3f,0xff,0xff,0xff
,0xff,0xff,0xff,0xe1,0xf8,0x61,0xe1,0xc3,0x0f,0xc3,0x0f,0x8c,0x3f,0xff,0xff,0xff
,0xff,0xff,0xff,0xe1,0xf8,0x70,0xc3,0xc3,0x0f,0xc3,0x0f,0x0e,0x1f,0xff,0xff,0xff
,0xff,0xff,0xff,0xe1,0xf8,0x70,0xc3,0xc3,0x0f,0xc3,0x0f,0x0e,0x1f,0xff,0xff,0xff
,0xff,0xff,0xff,0xe1,0xf8,0x70,0xc3,0xc3,0x0f,0xc3,0x0f,0x1f,0x1f,0xff,0xff,0xff
,0xff,0xff,0xff,0xe1,0xf8,0x70,0xc7,0xc3,0x0f,0xc3,0x0e,0x00,0x0f,0xff,0xff,0xff
,0xff,0xff,0xff,0xe1,0xf8,0x78,0x07,0xc3,0x0f,0x83,0x0e,0x00,0x0f,0xff,0xff,0xff
,0xff,0xff,0xff,0xe1,0xf8,0x78,0x07,0xc3,0x00,0x07,0x0c,0x00,0x07,0xff,0xff,0xff
,0xff,0xff,0xff,0xe1,0xf8,0x78,0x0f,0xc3,0x00,0x0f,0x0c,0x3f,0x87,0xff,0xff,0xff
,0xff,0xff,0xff,0xe1,0xf8,0x7c,0x0f,0xc3,0x00,0x1f,0x0c,0x3f,0x87,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
void u8g_nvidia_logo_dark(void) {
// Bright logo on overall dark background.
u8g.drawBitmapP( 0, 0, 16, 64, nvidia_bitmap_dark);
}
void u8g_nvidia_logo_bright(void) {
// Dark logo on overall bright background.
u8g.drawBitmapP( 0, 0, 16, 64, nvidia_bitmap_bright);
}
void u8g_shatter_glass(uint8_t a) {
uint16_t offset = a;
// The glass pane breaks into 4 shards.
// Each shard is a triangle moving away from the centre.
// Upon each invocation of this function,
// the shards are drawn progresively further apart using the offset.
u8g.drawTriangle(14-offset*2,7, 45-offset*2,30, 10-offset*2,40);
u8g.drawTriangle(14+offset,7-offset, 45+offset,30-offset, 57+offset,10-offset);
u8g.drawTriangle(57+offset*2,10, 45+offset*2,30, 86+offset*2,53);
u8g.drawTriangle(10+offset,40+offset, 45+offset,30+offset, 86+offset,53+offset);
}
void draw(uint8_t frame_counter) {
// 256 frames in a loop.
// Render each demo for a quarter of the loop
// 0x40 = 0b01000000 frames each
switch(frame_counter >> 6) {
case 0: u8g_nvidia_logo_dark(); break;
case 1: u8g_shatter_glass(frame_counter&15); break;
case 2: u8g_nvidia_logo_bright(); break;
case 3: u8g_shatter_glass(frame_counter&15); break;
}
}
void printHex(uint8_t num, uint8_t x, uint8_t y)
{
// call procedure from base class, http://arduino.cc/en/Serial/Print
switch (num) {
case 0: u8g.drawStr(x, y, "0"); break;
case 1: u8g.drawStr(x, y, "1"); break;
case 2: u8g.drawStr(x, y, "2"); break;
case 3: u8g.drawStr(x, y, "3"); break;
case 4: u8g.drawStr(x, y, "4"); break;
case 5: u8g.drawStr(x, y, "5"); break;
case 6: u8g.drawStr(x, y, "6"); break;
case 7: u8g.drawStr(x, y, "7"); break;
case 8: u8g.drawStr(x, y, "8"); break;
case 9: u8g.drawStr(x, y, "9"); break;
case 10: u8g.drawStr(x, y, "a"); break;
case 11: u8g.drawStr(x, y, "b"); break;
case 12: u8g.drawStr(x, y, "c"); break;
case 13: u8g.drawStr(x, y, "d"); break;
case 14: u8g.drawStr(x, y, "e"); break;
case 15: u8g.drawStr(x, y, "f"); break;
}
}
void print8bitHex(uint8_t num, uint8_t x, uint8_t y)
{
printHex((num & 0xf0)>>4, x, y); // print the upper nibble
printHex(num & 0x0f, x+6, y); // print the lower nibble
}
void print16bitHex(uint16_t num, uint8_t x, uint8_t y)
{
printHex((num & 0xf000)>>12, x, y); // print 3rd nibble (MSB)
printHex((num & 0xf00)>>8, x+6, y); // print 2nd nibble (MSB)
printHex((num & 0xf0)>>4, x+12, y); // print 1st nibble (LSB)
printHex(num & 0x0f, x+18, y); // print 0th nibble (LSB)
}
void setup(void) {
//u8g.setRot180(); // flip screen, if required
u8g.setFont(u8g_font_6x10); // plain-old text mode :P
u8g.setFontRefHeightExtendedText();
u8g.setDefaultForegroundColor();
u8g.setFontPosTop();
pinMode(13, OUTPUT);
digitalWrite(13, HIGH); // LED ON = setup complete
}
void loop(void) {
static uint8_t draw_state = 0;
static uint16_t counter = 0;
// Main activity loop
u8g.firstPage(); // Beging frame update
do {
draw(draw_state); // render gfx
playMelody(); // play background music
counter++; // increment the internal-counter
print16bitHex(counter, 0, 0); // render text (internal-counter)
print8bitHex(draw_state, 0, 10); // render text (frame-counter)
} while( u8g.nextPage() ); // frame update in-progress
draw_state++; // increment the state (frame-counter)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment