[342] | 1 | /* Copyright (c) 2006 Rice University */ |
---|
| 2 | /* All Rights Reserved */ |
---|
| 3 | /* This code is covered by the Rice-WARP license */ |
---|
| 4 | /* See http://warp.rice.edu/license/ for details */ |
---|
| 5 | |
---|
| 6 | |
---|
[341] | 7 | #include "warplib.h" |
---|
| 8 | #include <stdlib.h> |
---|
| 9 | #include "xparameters.h" |
---|
| 10 | |
---|
| 11 | #include <string.h> |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | // a test function to make sure the library is being called correctly. |
---|
| 15 | |
---|
| 16 | void WarpLib_test(void) |
---|
| 17 | { |
---|
| 18 | print("This is a test function for the new TAP Library that we are developing. 1337."); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | // a basic int to character converter |
---|
| 22 | |
---|
| 23 | char WarpLib_itoc(int x) |
---|
| 24 | { |
---|
| 25 | char c = (char)(x+48); |
---|
| 26 | return c; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | // a basic character to int converter |
---|
| 30 | |
---|
| 31 | int WarpLib_ctoi(char c) |
---|
| 32 | { |
---|
| 33 | int x = (int)(c-48); |
---|
| 34 | return x; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | // 7 segment display mapper. Takes in desired char-type of a char or number |
---|
| 38 | // and gives out its corresponding 7-segment display code |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | int WarpLib_segmap(char x) |
---|
| 42 | { |
---|
| 43 | |
---|
| 44 | switch(x){ |
---|
| 45 | |
---|
| 46 | case('0') : return 0x007E; |
---|
| 47 | case('1') : return 0x0030; |
---|
| 48 | case('2') : return 0x006D; |
---|
| 49 | case('3') : return 0x0079; |
---|
| 50 | case('4') : return 0x0033; |
---|
| 51 | case('5') : return 0x005B; |
---|
| 52 | case('6') : return 0x005F; |
---|
| 53 | case('7') : return 0x0070; |
---|
| 54 | case('8') : return 0x007F; |
---|
| 55 | case('9') : return 0x007B; |
---|
| 56 | |
---|
| 57 | case('A') : return 0x0077; |
---|
| 58 | case('a') : return 0x0077; |
---|
| 59 | case('B') : return 0x007F; |
---|
| 60 | case('b') : return 0x007F; |
---|
| 61 | case('C') : return 0x004E; |
---|
| 62 | case('c') : return 0x004E; |
---|
| 63 | case('D') : return 0x007E; |
---|
| 64 | case('d') : return 0x007E; |
---|
| 65 | case('E') : return 0x004F; |
---|
| 66 | case('e') : return 0x004F; |
---|
| 67 | case('F') : return 0x0047; |
---|
| 68 | case('f') : return 0x0047; |
---|
| 69 | default : return 0x0001; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | |
---|