GB DS module

Modules, cases, buttons...

Re: GB DS module

Postby adekto » Wed Aug 05, 2015 1:04 pm

heres the hello world for the ds module
you will also need this library https://code.google.com/p/u8glib/

Code: Select all
//imports the library's
#include <SPI.h>
#include <Gamebuino.h>
#include <U8glib.h>
//creates a Gamebuino object named gb
Gamebuino gb;
//creates the ds object for the oled sceen
U8GLIB_SSD1306_128X64 ds(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST);


//sprite 48,64
const byte sprite[] PROGMEM = {0x4,0x80,0x0,0x0,0x0,0x0,0xC,0x80,0x0,0x0,0xFC,0x0,0x8,0x80,0x0,0x3,0x84,0x0,0x8,0xC0,0x0,0x6,0x44,0x0,0x19,0x40,0x0,0x1D,0x84,0x0,0x11,0x40,0x0,0x33,0x4,0x0,0x31,0x40,0x0,0xEE,0x6,0x0,0x21,0x73,0xE1,0x9C,0xA,0x0,0x23,0x9E,0x3F,0x78,0x12,0x0,0x23,0xE9,0x8C,0xF0,0x2,0x0,0x23,0xEA,0xEB,0xF0,0x2,0x0,0x23,0xF1,0x57,0xF0,0x2,0x0,0x69,0xF0,0xA7,0xF0,0x16,0x0,0x5E,0xF0,0x7,0xF8,0x34,0x0,0x5F,0xF8,0xF,0xFC,0x74,0x0,0x5F,0xF8,0xF,0xFE,0xF4,0x0,0x5F,0xFE,0x3F,0xFF,0xEC,0x0,0x6F,0x1F,0xFC,0x3F,0xE8,0x0,0x36,0xEF,0xFB,0xDF,0xD8,0x0,0x1A,0xD7,0xF6,0x6F,0xB0,0x0,0xC,0x87,0xF4,0x2D,0x30,0x0,0x8,0x87,0xF4,0x22,0xD8,0x0,0xC,0x8F,0xF4,0x27,0xEC,0x0,0xA,0xDF,0xFE,0x6F,0xF6,0x0,0x3B,0xFF,0xFF,0xFF,0xF2,0x0,0xE7,0xFF,0xFF,0xFF,0xC2,0x0,0x9F,0xFF,0xDF,0xFF,0xDA,0x0,0x9F,0xF8,0x1F,0xFF,0xEE,0x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begin();
  //display the main menu:
  gb.titleScreen(F("ds hello wold"));
  gb.popup(F("Let's go!"), 100);
}
void gbLoop(){
    //prints Hello World! on the screen
    gb.display.println(F("Hello ds module!"));
    //declare a variable named count of type integer :
    int count;
    //get the number of frames rendered and assign it to the "count" variable
    count = gb.frameCount;
    //prints the variable "count"
    gb.display.println(count);
    //move the sprite on the ds module
    if(y > 1){
      y = y - 1;
    }
}

void dsDraw(){
  // set the font for the ds module
  ds.setFont(u8g_font_unifont);
 
  ds.drawStr( 0, 22, "hi gamebuino!");
  ds.drawBitmapP( 79, y, 6, 64, sprite);
}

// the loop routine runs over and over again forever
void loop(){
  if(gb.update()){
  // normal gamebuino loop
  gbLoop();
 // picture loop for ds module
  ds.firstPage(); 
  do {
    dsDraw();
  } while( ds.nextPage() );
  }
 
}
User avatar
adekto
 
Posts: 448
Joined: Tue Feb 25, 2014 9:47 pm
Location: belgium

Previous

Return to Hardware Development

Who is online

Users browsing this forum: No registered users and 18 guests

cron