Louis Mayencourt / Mbed OS NRFBOY
Committer:
lmayencou
Date:
Thu Jan 05 18:37:50 2017 +0000
Revision:
0:649b2fe69f16
Child:
1:c53e766082b4
I2C screen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lmayencou 0:649b2fe69f16 1 /*
lmayencou 0:649b2fe69f16 2 Hello, World! example
lmayencou 0:649b2fe69f16 3 June 11, 2015
lmayencou 0:649b2fe69f16 4 Copyright (C) 2015 David Martinez
lmayencou 0:649b2fe69f16 5 All rights reserved.
lmayencou 0:649b2fe69f16 6 This code is the most basic barebones code for writing a program for Arduboy.
lmayencou 0:649b2fe69f16 7
lmayencou 0:649b2fe69f16 8 This library is free software; you can redistribute it and/or
lmayencou 0:649b2fe69f16 9 modify it under the terms of the GNU Lesser General Public
lmayencou 0:649b2fe69f16 10 License as published by the Free Software Foundation; either
lmayencou 0:649b2fe69f16 11 version 2.1 of the License, or (at your option) any later version.
lmayencou 0:649b2fe69f16 12 */
lmayencou 0:649b2fe69f16 13
lmayencou 0:649b2fe69f16 14 #include "arduboy.hpp"
lmayencou 0:649b2fe69f16 15
lmayencou 0:649b2fe69f16 16 // make an instance of arduboy used for many functions
lmayencou 0:649b2fe69f16 17 I2C i2c(p11,p12);
lmayencou 0:649b2fe69f16 18 //DigitalOut led2(LED2);
lmayencou 0:649b2fe69f16 19 Arduboy arduboy(i2c);
lmayencou 0:649b2fe69f16 20
lmayencou 0:649b2fe69f16 21 // This function runs once in your game.
lmayencou 0:649b2fe69f16 22 // use it for anything that needs to be set only once in your game.
lmayencou 0:649b2fe69f16 23 void setup() {
lmayencou 0:649b2fe69f16 24 // led2 = 0;
lmayencou 0:649b2fe69f16 25 // initiate arduboy instance
lmayencou 0:649b2fe69f16 26 arduboy.begin();
lmayencou 0:649b2fe69f16 27
lmayencou 0:649b2fe69f16 28
lmayencou 0:649b2fe69f16 29 // here we set the framerate to 15, we do not need to run at
lmayencou 0:649b2fe69f16 30 // default 60 and it saves us battery life
lmayencou 0:649b2fe69f16 31 // arduboy.setFrameRate(15);
lmayencou 0:649b2fe69f16 32 }
lmayencou 0:649b2fe69f16 33
lmayencou 0:649b2fe69f16 34
lmayencou 0:649b2fe69f16 35 // our main game loop, this runs once every cycle/frame.
lmayencou 0:649b2fe69f16 36 // this is where our game logic goes.
lmayencou 0:649b2fe69f16 37 void loop() {
lmayencou 0:649b2fe69f16 38 // pause render until it's time for the next frame
lmayencou 0:649b2fe69f16 39 // if (!(arduboy.nextFrame()))
lmayencou 0:649b2fe69f16 40 // return;
lmayencou 0:649b2fe69f16 41
lmayencou 0:649b2fe69f16 42 // wait_ms(2000);
lmayencou 0:649b2fe69f16 43 // led2 = 1;
lmayencou 0:649b2fe69f16 44 // first we clear our screen to black
lmayencou 0:649b2fe69f16 45 // arduboy.clear();
lmayencou 0:649b2fe69f16 46 // wait_ms(2000);
lmayencou 0:649b2fe69f16 47 // led2 = 0;
lmayencou 0:649b2fe69f16 48 // we set our cursor 5 pixels to the right and 10 down from the top
lmayencou 0:649b2fe69f16 49 // (positions start at 0, 0)
lmayencou 0:649b2fe69f16 50 //arduboy.setCursor(4, 9);
lmayencou 0:649b2fe69f16 51
lmayencou 0:649b2fe69f16 52 // then we print to screen what is in the Quotation marks ""
lmayencou 0:649b2fe69f16 53 //arduboy.printf("Hello, world!");
lmayencou 0:649b2fe69f16 54 // wait_ms(2000);
lmayencou 0:649b2fe69f16 55 // led2 = 1;
lmayencou 0:649b2fe69f16 56
lmayencou 0:649b2fe69f16 57 // then we finaly we tell the arduboy to display what we just wrote to the display
lmayencou 0:649b2fe69f16 58 // arduboy.display();
lmayencou 0:649b2fe69f16 59 }