![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
bio robot
Dependencies: MPU6050-DMP QEI_hw mbed-rpc mbed
Fork of MPU6050_Example by
Comm/json.h@20:f13b949b623b, 2015-12-11 (annotated)
- Committer:
- amandaghassaei
- Date:
- Fri Dec 11 08:54:32 2015 +0000
- Revision:
- 20:f13b949b623b
- Parent:
- 2:17b18ea93551
publish
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
amandaghassaei | 2:17b18ea93551 | 1 | #ifndef JSON_h |
amandaghassaei | 2:17b18ea93551 | 2 | #define JSON_h |
amandaghassaei | 2:17b18ea93551 | 3 | |
amandaghassaei | 2:17b18ea93551 | 4 | #include "mbed.h" |
amandaghassaei | 2:17b18ea93551 | 5 | |
amandaghassaei | 2:17b18ea93551 | 6 | class JSON { |
amandaghassaei | 2:17b18ea93551 | 7 | |
amandaghassaei | 2:17b18ea93551 | 8 | public: |
amandaghassaei | 2:17b18ea93551 | 9 | |
amandaghassaei | 2:17b18ea93551 | 10 | JSON(Serial* pc){ |
amandaghassaei | 2:17b18ea93551 | 11 | _pc = pc; |
amandaghassaei | 2:17b18ea93551 | 12 | } |
amandaghassaei | 2:17b18ea93551 | 13 | |
amandaghassaei | 2:17b18ea93551 | 14 | void open(){ |
amandaghassaei | 2:17b18ea93551 | 15 | _pc->printf("{"); |
amandaghassaei | 2:17b18ea93551 | 16 | } |
amandaghassaei | 2:17b18ea93551 | 17 | |
amandaghassaei | 2:17b18ea93551 | 18 | void close(){ |
amandaghassaei | 2:17b18ea93551 | 19 | _pc->printf("}\n"); |
amandaghassaei | 2:17b18ea93551 | 20 | } |
amandaghassaei | 2:17b18ea93551 | 21 | |
amandaghassaei | 2:17b18ea93551 | 22 | void sepItem(){ |
amandaghassaei | 2:17b18ea93551 | 23 | _pc->printf(","); |
amandaghassaei | 2:17b18ea93551 | 24 | } |
amandaghassaei | 2:17b18ea93551 | 25 | |
amandaghassaei | 2:17b18ea93551 | 26 | void print(char *key, float value){ |
amandaghassaei | 2:17b18ea93551 | 27 | _pc->printf("\""); |
amandaghassaei | 2:17b18ea93551 | 28 | _pc->printf(key); |
amandaghassaei | 2:17b18ea93551 | 29 | _pc->printf("\": \""); |
amandaghassaei | 2:17b18ea93551 | 30 | _pc->printf("%f", value); |
amandaghassaei | 2:17b18ea93551 | 31 | _pc->printf("\""); |
amandaghassaei | 2:17b18ea93551 | 32 | } |
amandaghassaei | 2:17b18ea93551 | 33 | |
amandaghassaei | 2:17b18ea93551 | 34 | void print(char *key, int value){ |
amandaghassaei | 2:17b18ea93551 | 35 | _pc->printf("\""); |
amandaghassaei | 2:17b18ea93551 | 36 | _pc->printf(key); |
amandaghassaei | 2:17b18ea93551 | 37 | _pc->printf("\": \""); |
amandaghassaei | 2:17b18ea93551 | 38 | _pc->printf("%i", value); |
amandaghassaei | 2:17b18ea93551 | 39 | _pc->printf("\""); |
amandaghassaei | 2:17b18ea93551 | 40 | } |
amandaghassaei | 2:17b18ea93551 | 41 | |
amandaghassaei | 2:17b18ea93551 | 42 | void print(char *key, char *value){ |
amandaghassaei | 2:17b18ea93551 | 43 | _pc->printf("\""); |
amandaghassaei | 2:17b18ea93551 | 44 | _pc->printf(key); |
amandaghassaei | 2:17b18ea93551 | 45 | _pc->printf("\": \""); |
amandaghassaei | 2:17b18ea93551 | 46 | _pc->printf(value); |
amandaghassaei | 2:17b18ea93551 | 47 | _pc->printf("\""); |
amandaghassaei | 2:17b18ea93551 | 48 | } |
amandaghassaei | 2:17b18ea93551 | 49 | |
amandaghassaei | 2:17b18ea93551 | 50 | private: |
amandaghassaei | 2:17b18ea93551 | 51 | |
amandaghassaei | 2:17b18ea93551 | 52 | Serial *_pc; |
amandaghassaei | 2:17b18ea93551 | 53 | |
amandaghassaei | 2:17b18ea93551 | 54 | |
amandaghassaei | 2:17b18ea93551 | 55 | }; |
amandaghassaei | 2:17b18ea93551 | 56 | |
amandaghassaei | 2:17b18ea93551 | 57 | #endif |