Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
helloworld.hpp@1:c53e766082b4, 2017-01-06 (annotated)
- Committer:
 - lmayencou
 - Date:
 - Fri Jan 06 22:10:20 2017 +0000
 - Revision:
 - 1:c53e766082b4
 - Parent:
 - 0:649b2fe69f16
 - Child:
 - 2:e3ef9f476913
 
display circle and hello on SPI screen !
Who changed what in which revision?
| User | Revision | Line number | New 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 | 1:c53e766082b4 | 14 | #include "mbedboy.hpp" | 
| lmayencou | 0:649b2fe69f16 | 15 | |
| lmayencou | 0:649b2fe69f16 | 16 | // make an instance of arduboy used for many functions | 
| lmayencou | 1:c53e766082b4 | 17 | |
| lmayencou | 1:c53e766082b4 | 18 | DigitalOut led2(LED2); | 
| lmayencou | 1:c53e766082b4 | 19 | DigitalOut led3(LED3); | 
| lmayencou | 1:c53e766082b4 | 20 | |
| lmayencou | 1:c53e766082b4 | 21 | MbedBoy arduboy; | 
| lmayencou | 0:649b2fe69f16 | 22 | |
| lmayencou | 0:649b2fe69f16 | 23 | // This function runs once in your game. | 
| lmayencou | 0:649b2fe69f16 | 24 | // use it for anything that needs to be set only once in your game. | 
| lmayencou | 0:649b2fe69f16 | 25 | void setup() { | 
| lmayencou | 1:c53e766082b4 | 26 | printf("start setup"); | 
| lmayencou | 1:c53e766082b4 | 27 | led2 = 0; | 
| lmayencou | 1:c53e766082b4 | 28 | led3 = 0; | 
| lmayencou | 0:649b2fe69f16 | 29 | // initiate arduboy instance | 
| lmayencou | 1:c53e766082b4 | 30 | arduboy.start(); | 
| lmayencou | 0:649b2fe69f16 | 31 | |
| lmayencou | 1:c53e766082b4 | 32 | arduboy.blank(); | 
| lmayencou | 0:649b2fe69f16 | 33 | |
| lmayencou | 0:649b2fe69f16 | 34 | // here we set the framerate to 15, we do not need to run at | 
| lmayencou | 0:649b2fe69f16 | 35 | // default 60 and it saves us battery life | 
| lmayencou | 0:649b2fe69f16 | 36 | // arduboy.setFrameRate(15); | 
| lmayencou | 1:c53e766082b4 | 37 | printf("end setup"); | 
| lmayencou | 0:649b2fe69f16 | 38 | } | 
| lmayencou | 0:649b2fe69f16 | 39 | |
| lmayencou | 0:649b2fe69f16 | 40 | |
| lmayencou | 0:649b2fe69f16 | 41 | // our main game loop, this runs once every cycle/frame. | 
| lmayencou | 0:649b2fe69f16 | 42 | // this is where our game logic goes. | 
| lmayencou | 0:649b2fe69f16 | 43 | void loop() { | 
| lmayencou | 1:c53e766082b4 | 44 | printf("start loop"); | 
| lmayencou | 0:649b2fe69f16 | 45 | // pause render until it's time for the next frame | 
| lmayencou | 0:649b2fe69f16 | 46 | // if (!(arduboy.nextFrame())) | 
| lmayencou | 0:649b2fe69f16 | 47 | // return; | 
| lmayencou | 0:649b2fe69f16 | 48 | |
| lmayencou | 0:649b2fe69f16 | 49 | // wait_ms(2000); | 
| lmayencou | 0:649b2fe69f16 | 50 | // led2 = 1; | 
| lmayencou | 0:649b2fe69f16 | 51 | // first we clear our screen to black | 
| lmayencou | 1:c53e766082b4 | 52 | // arduboy.clear(); | 
| lmayencou | 0:649b2fe69f16 | 53 | // wait_ms(2000); | 
| lmayencou | 0:649b2fe69f16 | 54 | // led2 = 0; | 
| lmayencou | 0:649b2fe69f16 | 55 | // we set our cursor 5 pixels to the right and 10 down from the top | 
| lmayencou | 0:649b2fe69f16 | 56 | // (positions start at 0, 0) | 
| lmayencou | 1:c53e766082b4 | 57 | arduboy.setTextCursor(1, 1); | 
| lmayencou | 1:c53e766082b4 | 58 | arduboy.writeChar('h'); | 
| lmayencou | 1:c53e766082b4 | 59 | arduboy.writeChar('e'); | 
| lmayencou | 1:c53e766082b4 | 60 | arduboy.writeChar('l'); | 
| lmayencou | 1:c53e766082b4 | 61 | arduboy.writeChar('l'); | 
| lmayencou | 1:c53e766082b4 | 62 | arduboy.writeChar('o'); | 
| lmayencou | 0:649b2fe69f16 | 63 | // then we print to screen what is in the Quotation marks "" | 
| lmayencou | 0:649b2fe69f16 | 64 | //arduboy.printf("Hello, world!"); | 
| lmayencou | 0:649b2fe69f16 | 65 | // wait_ms(2000); | 
| lmayencou | 1:c53e766082b4 | 66 | led2 = 1; | 
| lmayencou | 0:649b2fe69f16 | 67 | |
| lmayencou | 1:c53e766082b4 | 68 | arduboy.drawCircle(30,30,30,WHITE); | 
| lmayencou | 0:649b2fe69f16 | 69 | // then we finaly we tell the arduboy to display what we just wrote to the display | 
| lmayencou | 1:c53e766082b4 | 70 | arduboy.display(); | 
| lmayencou | 1:c53e766082b4 | 71 | led3 = 1; | 
| lmayencou | 1:c53e766082b4 | 72 | printf("end loop"); | 
| lmayencou | 0:649b2fe69f16 | 73 | } |