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@1:47394b602697, 2019-03-13 (annotated)
- Committer:
- Yehowshua Immanuel
- Date:
- Wed Mar 13 09:45:21 2019 -0400
- Revision:
- 1:47394b602697
- Parent:
- 0:2f4225a589d1
- Child:
- 3:0e14def93d4e
Ass hashtable
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 | 0:2f4225a589d1 | 3 | #include "main_character.h" |
| Yehowshua Immanuel |
1:47394b602697 | 4 | #include "./hash_table/hash_table.h" |
| Yehowshua | 0:2f4225a589d1 | 5 | |
| Yehowshua | 0:2f4225a589d1 | 6 | uLCD_4DGL uLCD(p9, p10, p11); // serial tx, serial rx, reset pin; |
| Yehowshua Immanuel |
1:47394b602697 | 7 | Serial pc(USBTX, USBRX); |
| Yehowshua | 0:2f4225a589d1 | 8 | |
| Yehowshua | 0:2f4225a589d1 | 9 | |
| Yehowshua | 0:2f4225a589d1 | 10 | extern void main_character_constructor(void); |
| Yehowshua Immanuel |
1:47394b602697 | 11 | //extern void* insertItem(HashTable* myHashTable, unsigned int key, void* value); |
| Yehowshua | 0:2f4225a589d1 | 12 | extern sprite main_character; |
| Yehowshua Immanuel |
1:47394b602697 | 13 | int *test_val; |
| Yehowshua Immanuel |
1:47394b602697 | 14 | int *returned_val; |
| Yehowshua Immanuel |
1:47394b602697 | 15 | |
| Yehowshua Immanuel |
1:47394b602697 | 16 | //key function |
| Yehowshua Immanuel |
1:47394b602697 | 17 | unsigned int genKey(unsigned int key){ |
| Yehowshua Immanuel |
1:47394b602697 | 18 | return key%97; |
| Yehowshua Immanuel |
1:47394b602697 | 19 | } |
| Yehowshua | 0:2f4225a589d1 | 20 | |
| Yehowshua | 0:2f4225a589d1 | 21 | DigitalOut myled(LED1); |
| Yehowshua | 0:2f4225a589d1 | 22 | |
| Yehowshua | 0:2f4225a589d1 | 23 | int main() { |
| Yehowshua Immanuel |
1:47394b602697 | 24 | *test_val = 22; |
| Yehowshua | 0:2f4225a589d1 | 25 | //increase BAUD rate |
| Yehowshua | 0:2f4225a589d1 | 26 | uLCD.baudrate(3000000); |
| Yehowshua | 0:2f4225a589d1 | 27 | uLCD.background_color(WHITE); |
| Yehowshua | 0:2f4225a589d1 | 28 | |
| Yehowshua Immanuel |
1:47394b602697 | 29 | //hash table |
| Yehowshua Immanuel |
1:47394b602697 | 30 | //create hash table structs |
| Yehowshua Immanuel |
1:47394b602697 | 31 | HashTable* map[1]; |
| Yehowshua Immanuel |
1:47394b602697 | 32 | //populate create hash table |
| Yehowshua Immanuel |
1:47394b602697 | 33 | map[0] = createHashTable(genKey,(unsigned int)97); |
| Yehowshua Immanuel |
1:47394b602697 | 34 | //create and retrieve test key |
| Yehowshua Immanuel |
1:47394b602697 | 35 | void* val = insertItem(map[0], 33, test_val); |
| Yehowshua Immanuel |
1:47394b602697 | 36 | returned_val = (int*)getItem(map[0], 33); |
| Yehowshua Immanuel |
1:47394b602697 | 37 | |
| Yehowshua Immanuel |
1:47394b602697 | 38 | //print returned value |
| Yehowshua Immanuel |
1:47394b602697 | 39 | pc.printf("The reuturned value is %d\n",*returned_val); |
| Yehowshua Immanuel |
1:47394b602697 | 40 | |
| Yehowshua | 0:2f4225a589d1 | 41 | main_character_constructor(); |
| Yehowshua | 0:2f4225a589d1 | 42 | //main_character_i(); |
| Yehowshua | 0:2f4225a589d1 | 43 | uLCD.BLIT(0,0,16,16,main_character.skins); |
| Yehowshua | 0:2f4225a589d1 | 44 | uLCD.BLIT(15,15,16,16,main_character.skins); |
| Yehowshua | 0:2f4225a589d1 | 45 | uLCD.BLIT(31,31,16,16,main_character.skins); |
| Yehowshua | 0:2f4225a589d1 | 46 | while(1) { |
| Yehowshua | 0:2f4225a589d1 | 47 | myled = 1; |
| Yehowshua | 0:2f4225a589d1 | 48 | wait(0.2); |
| Yehowshua | 0:2f4225a589d1 | 49 | myled = 0; |
| Yehowshua | 0:2f4225a589d1 | 50 | wait(0.2); |
| Yehowshua | 0:2f4225a589d1 | 51 | } |
| Yehowshua | 0:2f4225a589d1 | 52 | } |