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.
Dependencies: mbed 4DGL-uLCD-SE MMA8452
main.cpp@4:fb7d49e660f2, 2019-03-16 (annotated)
- Committer:
- Yehowshua
- Date:
- Sat Mar 16 05:25:19 2019 +0000
- Revision:
- 4:fb7d49e660f2
- Parent:
- 3:0e14def93d4e
now with inputs
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Yehowshua | 0:2f4225a589d1 | 1 | #include "mbed.h" |
| Yehowshua | 0:2f4225a589d1 | 2 | #include "uLCD_4DGL.h" |
| Yehowshua Immanuel |
3:0e14def93d4e | 3 | #include "Sprites/main_character/main_character.h" |
| Yehowshua Immanuel |
3:0e14def93d4e | 4 | #include "hash_table/hash_table.h" |
| Yehowshua Immanuel |
3:0e14def93d4e | 5 | #include "worlds/worlds.h" |
| Yehowshua | 4:fb7d49e660f2 | 6 | #include "inputs/inputs.h" |
| Yehowshua | 0:2f4225a589d1 | 7 | |
| Yehowshua | 0:2f4225a589d1 | 8 | uLCD_4DGL uLCD(p9, p10, p11); // serial tx, serial rx, reset pin; |
| Yehowshua Immanuel |
1:47394b602697 | 9 | Serial pc(USBTX, USBRX); |
| Yehowshua | 0:2f4225a589d1 | 10 | |
| Yehowshua | 0:2f4225a589d1 | 11 | |
| Yehowshua Immanuel |
1:47394b602697 | 12 | |
| Yehowshua Immanuel |
1:47394b602697 | 13 | //key function |
| Yehowshua Immanuel |
1:47394b602697 | 14 | unsigned int genKey(unsigned int key){ |
| Yehowshua Immanuel |
1:47394b602697 | 15 | return key%97; |
| Yehowshua Immanuel |
1:47394b602697 | 16 | } |
| Yehowshua | 0:2f4225a589d1 | 17 | |
| Yehowshua Immanuel |
3:0e14def93d4e | 18 | DigitalOut myled(LED2); |
| Yehowshua Immanuel |
3:0e14def93d4e | 19 | |
| Yehowshua Immanuel |
3:0e14def93d4e | 20 | void initWorlds(void){ |
| Yehowshua Immanuel |
3:0e14def93d4e | 21 | initialize_sprites(); |
| Yehowshua Immanuel |
3:0e14def93d4e | 22 | allocate_worlds(); |
| Yehowshua Immanuel |
3:0e14def93d4e | 23 | populate_worlds(); |
| Yehowshua Immanuel |
3:0e14def93d4e | 24 | } |
| Yehowshua | 0:2f4225a589d1 | 25 | |
| Yehowshua | 0:2f4225a589d1 | 26 | int main() { |
| Yehowshua | 0:2f4225a589d1 | 27 | //increase BAUD rate |
| Yehowshua | 0:2f4225a589d1 | 28 | uLCD.baudrate(3000000); |
| Yehowshua | 0:2f4225a589d1 | 29 | uLCD.background_color(WHITE); |
| Yehowshua Immanuel |
3:0e14def93d4e | 30 | initWorlds(); |
| Yehowshua Immanuel |
3:0e14def93d4e | 31 | sprite* ret_sprite; |
| Yehowshua | 4:fb7d49e660f2 | 32 | inputs_init(); |
| Yehowshua | 0:2f4225a589d1 | 33 | |
| Yehowshua Immanuel |
3:0e14def93d4e | 34 | |
| Yehowshua Immanuel |
3:0e14def93d4e | 35 | for(int y = 0; y < 8; y+=1){ |
| Yehowshua Immanuel |
3:0e14def93d4e | 36 | for(int x = 0; x < 8; x+=1){ |
| Yehowshua Immanuel |
3:0e14def93d4e | 37 | //uLCD.BLIT(j,i,16,16,main_character.render.activeSkin); |
| Yehowshua Immanuel |
3:0e14def93d4e | 38 | ret_sprite = (sprite*)fetchSprite(x,y); |
| Yehowshua Immanuel |
3:0e14def93d4e | 39 | if(ret_sprite == NULL) |
| Yehowshua Immanuel |
3:0e14def93d4e | 40 | continue; |
| Yehowshua Immanuel |
3:0e14def93d4e | 41 | uLCD.BLIT(x*16,y*16,16,16,(*ret_sprite).render.activeSkin); |
| Yehowshua Immanuel |
1:47394b602697 | 42 | |
| Yehowshua Immanuel |
3:0e14def93d4e | 43 | } |
| Yehowshua Immanuel |
3:0e14def93d4e | 44 | } |
| Yehowshua Immanuel |
1:47394b602697 | 45 | |
| Yehowshua | 0:2f4225a589d1 | 46 | main_character_constructor(); |
| Yehowshua | 0:2f4225a589d1 | 47 | //main_character_i(); |
| Yehowshua | 0:2f4225a589d1 | 48 | while(1) { |
| Yehowshua | 0:2f4225a589d1 | 49 | myled = 1; |
| Yehowshua | 0:2f4225a589d1 | 50 | wait(0.2); |
| Yehowshua | 4:fb7d49e660f2 | 51 | pc.printf("VALUE %d\r\n",get_inputs()); |
| Yehowshua | 0:2f4225a589d1 | 52 | myled = 0; |
| Yehowshua | 0:2f4225a589d1 | 53 | wait(0.2); |
| Yehowshua | 0:2f4225a589d1 | 54 | } |
| Yehowshua | 0:2f4225a589d1 | 55 | } |