Eduard Sjoukes
/
DatatypesLength
Showing the length of mbed datatypes in bytes.
main.cpp@1:275d27c2d033, 2010-12-05 (annotated)
- Committer:
- Eduard
- Date:
- Sun Dec 05 12:14:51 2010 +0000
- Revision:
- 1:275d27c2d033
- Parent:
- 0:124a3cf10d74
Also the \" bool\" type included now
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Eduard | 0:124a3cf10d74 | 1 | /************************************************************************* |
Eduard | 0:124a3cf10d74 | 2 | * Gets the length of mbeds datatypes and display those on a 20x4 Optrex LCD |
Eduard | 0:124a3cf10d74 | 3 | * This LCD needs a different timing than a normal LCD, see the |
Eduard | 0:124a3cf10d74 | 4 | * OptrexLCD program for more information. |
Eduard | 0:124a3cf10d74 | 5 | **************************************************************************/ |
Eduard | 0:124a3cf10d74 | 6 | |
Eduard | 0:124a3cf10d74 | 7 | #include "mbed.h" |
Eduard | 0:124a3cf10d74 | 8 | #include "OptrexLCD.h" |
Eduard | 0:124a3cf10d74 | 9 | |
Eduard | 0:124a3cf10d74 | 10 | DigitalOut BlinkLed(LED4); |
Eduard | 0:124a3cf10d74 | 11 | |
Eduard | 0:124a3cf10d74 | 12 | TextLCD lcd(p10, p12, p15, p16, p17, p18, TextLCD::LCD20x4 ); // rs, e, d0-d3 |
Eduard | 0:124a3cf10d74 | 13 | |
Eduard | 0:124a3cf10d74 | 14 | void WaitRefres() // procedure for showing the result for 3 seconds before getting the next datatypes |
Eduard | 0:124a3cf10d74 | 15 | { |
Eduard | 0:124a3cf10d74 | 16 | wait(3); |
Eduard | 0:124a3cf10d74 | 17 | lcd.cls(); |
Eduard | 0:124a3cf10d74 | 18 | BlinkLed = !BlinkLed; |
Eduard | 0:124a3cf10d74 | 19 | } |
Eduard | 0:124a3cf10d74 | 20 | |
Eduard | 0:124a3cf10d74 | 21 | int main() |
Eduard | 0:124a3cf10d74 | 22 | { |
Eduard | 0:124a3cf10d74 | 23 | BlinkLed = 1; // show the program is running |
Eduard | 0:124a3cf10d74 | 24 | while(1) |
Eduard | 0:124a3cf10d74 | 25 | { |
Eduard | 0:124a3cf10d74 | 26 | lcd.printf("sizeof(char) == %d\n", sizeof(char)); |
Eduard | 0:124a3cf10d74 | 27 | lcd.printf("sizeof(short) == %d\n", sizeof(short)); |
Eduard | 0:124a3cf10d74 | 28 | lcd.printf("sizeof(int) == %d\n", sizeof(int)); |
Eduard | 0:124a3cf10d74 | 29 | lcd.printf("sizeof(long) == %d\n", sizeof(long)); |
Eduard | 0:124a3cf10d74 | 30 | WaitRefres(); |
Eduard | 0:124a3cf10d74 | 31 | |
Eduard | 0:124a3cf10d74 | 32 | lcd.printf("sizeof(float) == %d\n", sizeof(float)); |
Eduard | 0:124a3cf10d74 | 33 | lcd.printf("sizeof(double) == %d\n", sizeof(double)); |
Eduard | 1:275d27c2d033 | 34 | lcd.printf("sizeof(bool) == %d\n", sizeof(bool)); |
Eduard | 0:124a3cf10d74 | 35 | WaitRefres(); |
Eduard | 0:124a3cf10d74 | 36 | |
Eduard | 0:124a3cf10d74 | 37 | lcd.printf("sizeof(long double)\n == %d\n", sizeof(long double)); |
Eduard | 0:124a3cf10d74 | 38 | lcd.printf("sizeof(long long)\n == %d\n", sizeof(long long)); |
Eduard | 0:124a3cf10d74 | 39 | WaitRefres(); |
Eduard | 0:124a3cf10d74 | 40 | } |
Eduard | 0:124a3cf10d74 | 41 | } |