![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
a demo of GUI on DISCOF7 consisting of a few buttons and feeders
Dependencies: ADXL345 BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
main.cpp@4:8c94c3ee8a3a, 2016-08-06 (annotated)
- Committer:
- habiburrahman
- Date:
- Sat Aug 06 02:58:22 2016 +0000
- Revision:
- 4:8c94c3ee8a3a
- Parent:
- 3:afd2bb1331a4
- Child:
- 5:bb525217a976
few cleanup
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
habiburrahman | 0:122b5c3cbf4d | 1 | #include "mbed.h" |
habiburrahman | 0:122b5c3cbf4d | 2 | #include "TS_DISCO_F746NG.h" |
habiburrahman | 0:122b5c3cbf4d | 3 | #include "LCD_DISCO_F746NG.h" |
habiburrahman | 0:122b5c3cbf4d | 4 | #include "ESP8266.h" |
habiburrahman | 0:122b5c3cbf4d | 5 | #include "TCPSocketConnection.h" |
habiburrahman | 0:122b5c3cbf4d | 6 | #include <string> |
habiburrahman | 0:122b5c3cbf4d | 7 | using namespace std; |
habiburrahman | 0:122b5c3cbf4d | 8 | |
habiburrahman | 3:afd2bb1331a4 | 9 | |
habiburrahman | 3:afd2bb1331a4 | 10 | #define BUTTON_DEPRESS_TIME_MIN 0.065000f |
habiburrahman | 0:122b5c3cbf4d | 11 | |
habiburrahman | 0:122b5c3cbf4d | 12 | |
habiburrahman | 0:122b5c3cbf4d | 13 | LCD_DISCO_F746NG lcd; |
habiburrahman | 0:122b5c3cbf4d | 14 | TS_DISCO_F746NG ts; |
habiburrahman | 0:122b5c3cbf4d | 15 | TS_StateTypeDef TS_State; |
habiburrahman | 3:afd2bb1331a4 | 16 | |
habiburrahman | 3:afd2bb1331a4 | 17 | typedef struct{ |
habiburrahman | 3:afd2bb1331a4 | 18 | uint16_t x; |
habiburrahman | 3:afd2bb1331a4 | 19 | uint16_t y; |
habiburrahman | 3:afd2bb1331a4 | 20 | uint16_t width; |
habiburrahman | 3:afd2bb1331a4 | 21 | uint16_t height; |
habiburrahman | 3:afd2bb1331a4 | 22 | }rectData_t; |
habiburrahman | 0:122b5c3cbf4d | 23 | |
habiburrahman | 3:afd2bb1331a4 | 24 | typedef struct{ |
habiburrahman | 3:afd2bb1331a4 | 25 | rectData_t rectObj; |
habiburrahman | 3:afd2bb1331a4 | 26 | uint16_t value; |
habiburrahman | 3:afd2bb1331a4 | 27 | bool update_flag; |
habiburrahman | 3:afd2bb1331a4 | 28 | }hFeeder_t; |
habiburrahman | 3:afd2bb1331a4 | 29 | |
habiburrahman | 3:afd2bb1331a4 | 30 | typedef struct{ |
habiburrahman | 3:afd2bb1331a4 | 31 | rectData_t rectObj; |
habiburrahman | 3:afd2bb1331a4 | 32 | bool isPressed; |
habiburrahman | 3:afd2bb1331a4 | 33 | bool update_flag; |
habiburrahman | 3:afd2bb1331a4 | 34 | Timer depressTime; |
habiburrahman | 3:afd2bb1331a4 | 35 | }button_t; |
habiburrahman | 3:afd2bb1331a4 | 36 | |
habiburrahman | 0:122b5c3cbf4d | 37 | |
habiburrahman | 0:122b5c3cbf4d | 38 | |
habiburrahman | 3:afd2bb1331a4 | 39 | rectData_t but1pos = {48, 68, 96, 60}; |
habiburrahman | 3:afd2bb1331a4 | 40 | rectData_t but2pos = {192, 68, 96, 60}; |
habiburrahman | 3:afd2bb1331a4 | 41 | rectData_t but3pos = {338, 68, 96, 60}; |
habiburrahman | 3:afd2bb1331a4 | 42 | rectData_t hFeed1pos = {48, 152, 384, 30}; |
habiburrahman | 3:afd2bb1331a4 | 43 | rectData_t hFeed2pos = {48, 212, 384, 30}; |
habiburrahman | 0:122b5c3cbf4d | 44 | |
habiburrahman | 3:afd2bb1331a4 | 45 | button_t button1 = {but1pos,0,0}; |
habiburrahman | 3:afd2bb1331a4 | 46 | button_t button2 = {but2pos,0,0}; |
habiburrahman | 3:afd2bb1331a4 | 47 | button_t button3 = {but3pos,0,0}; |
habiburrahman | 3:afd2bb1331a4 | 48 | hFeeder_t hFeed1 = {hFeed1pos,0, 0}; |
habiburrahman | 3:afd2bb1331a4 | 49 | hFeeder_t hFeed2 = {hFeed2pos,0, 0}; |
habiburrahman | 3:afd2bb1331a4 | 50 | |
habiburrahman | 3:afd2bb1331a4 | 51 | void button(button_t *buttonObj, TS_StateTypeDef *TS_State){ |
habiburrahman | 0:122b5c3cbf4d | 52 | bool x_is_in =0; |
habiburrahman | 3:afd2bb1331a4 | 53 | bool y_is_in =0; |
habiburrahman | 3:afd2bb1331a4 | 54 | |
habiburrahman | 3:afd2bb1331a4 | 55 | uint16_t dyn_x = TS_State->touchX[0]; |
habiburrahman | 3:afd2bb1331a4 | 56 | uint16_t dyn_y = TS_State->touchY[0]; |
habiburrahman | 3:afd2bb1331a4 | 57 | |
habiburrahman | 3:afd2bb1331a4 | 58 | if( (dyn_x>buttonObj->rectObj.x) && (dyn_x<(buttonObj->rectObj.x+buttonObj->rectObj.width))) x_is_in = 1; |
habiburrahman | 3:afd2bb1331a4 | 59 | if( (dyn_y>buttonObj->rectObj.y) && (dyn_y<(buttonObj->rectObj.y+buttonObj->rectObj.height))) y_is_in = 1; |
habiburrahman | 0:122b5c3cbf4d | 60 | |
habiburrahman | 3:afd2bb1331a4 | 61 | if(x_is_in && y_is_in){ |
habiburrahman | 3:afd2bb1331a4 | 62 | if(!(buttonObj->isPressed)){ |
habiburrahman | 3:afd2bb1331a4 | 63 | buttonObj->depressTime.start(); |
habiburrahman | 3:afd2bb1331a4 | 64 | buttonObj->isPressed = 1; |
habiburrahman | 3:afd2bb1331a4 | 65 | lcd.SetTextColor(LCD_COLOR_GREEN); |
habiburrahman | 3:afd2bb1331a4 | 66 | lcd.FillRect(buttonObj->rectObj.x, buttonObj->rectObj.y, buttonObj->rectObj.width, buttonObj->rectObj.height); |
habiburrahman | 3:afd2bb1331a4 | 67 | } |
habiburrahman | 3:afd2bb1331a4 | 68 | } |
habiburrahman | 3:afd2bb1331a4 | 69 | |
habiburrahman | 0:122b5c3cbf4d | 70 | |
habiburrahman | 3:afd2bb1331a4 | 71 | else{ |
habiburrahman | 3:afd2bb1331a4 | 72 | if(buttonObj->isPressed){ |
habiburrahman | 3:afd2bb1331a4 | 73 | buttonObj->depressTime.stop(); |
habiburrahman | 3:afd2bb1331a4 | 74 | buttonObj->isPressed = 0; |
habiburrahman | 3:afd2bb1331a4 | 75 | if(buttonObj->depressTime.read()>BUTTON_DEPRESS_TIME_MIN){ |
habiburrahman | 3:afd2bb1331a4 | 76 | buttonObj->update_flag=1; |
habiburrahman | 3:afd2bb1331a4 | 77 | |
habiburrahman | 3:afd2bb1331a4 | 78 | } |
habiburrahman | 3:afd2bb1331a4 | 79 | buttonObj->depressTime.reset(); |
habiburrahman | 3:afd2bb1331a4 | 80 | lcd.SetTextColor(LCD_COLOR_RED); |
habiburrahman | 3:afd2bb1331a4 | 81 | lcd.FillRect(buttonObj->rectObj.x, buttonObj->rectObj.y, buttonObj->rectObj.width, buttonObj->rectObj.height); |
habiburrahman | 3:afd2bb1331a4 | 82 | } |
habiburrahman | 3:afd2bb1331a4 | 83 | } |
habiburrahman | 0:122b5c3cbf4d | 84 | } |
habiburrahman | 0:122b5c3cbf4d | 85 | |
habiburrahman | 0:122b5c3cbf4d | 86 | |
habiburrahman | 3:afd2bb1331a4 | 87 | void h_feeder(hFeeder_t *feederObj, TS_StateTypeDef *TS_State){ |
habiburrahman | 0:122b5c3cbf4d | 88 | bool x_is_in =0; |
habiburrahman | 0:122b5c3cbf4d | 89 | bool y_is_in =0; |
habiburrahman | 0:122b5c3cbf4d | 90 | |
habiburrahman | 3:afd2bb1331a4 | 91 | uint16_t dyn_x = TS_State->touchX[0]; |
habiburrahman | 3:afd2bb1331a4 | 92 | uint16_t dyn_y = TS_State->touchY[0]; |
habiburrahman | 0:122b5c3cbf4d | 93 | |
habiburrahman | 3:afd2bb1331a4 | 94 | if( (dyn_x>feederObj->rectObj.x) && (dyn_x<(feederObj->rectObj.x+feederObj->rectObj.width))) x_is_in = 1; |
habiburrahman | 3:afd2bb1331a4 | 95 | if( (dyn_y>feederObj->rectObj.y) && (dyn_y<(feederObj->rectObj.y+feederObj->rectObj.height))) y_is_in = 1; |
habiburrahman | 0:122b5c3cbf4d | 96 | |
habiburrahman | 3:afd2bb1331a4 | 97 | |
habiburrahman | 3:afd2bb1331a4 | 98 | if(x_is_in && y_is_in){ |
habiburrahman | 3:afd2bb1331a4 | 99 | uint16_t newFeedValue; |
habiburrahman | 3:afd2bb1331a4 | 100 | newFeedValue = dyn_x - feederObj->rectObj.x; |
habiburrahman | 3:afd2bb1331a4 | 101 | if(newFeedValue != feederObj->value){ |
habiburrahman | 3:afd2bb1331a4 | 102 | feederObj->update_flag = 1; |
habiburrahman | 3:afd2bb1331a4 | 103 | feederObj->value = newFeedValue; |
habiburrahman | 3:afd2bb1331a4 | 104 | |
habiburrahman | 3:afd2bb1331a4 | 105 | lcd.SetTextColor(LCD_COLOR_RED); |
habiburrahman | 3:afd2bb1331a4 | 106 | lcd.FillRect(feederObj->rectObj.x, feederObj->rectObj.y, feederObj->rectObj.width, feederObj->rectObj.height); |
habiburrahman | 3:afd2bb1331a4 | 107 | lcd.SetTextColor(LCD_COLOR_GREEN); |
habiburrahman | 3:afd2bb1331a4 | 108 | lcd.FillRect(feederObj->rectObj.x, feederObj->rectObj.y, feederObj->value, feederObj->rectObj.height); |
habiburrahman | 3:afd2bb1331a4 | 109 | } |
habiburrahman | 0:122b5c3cbf4d | 110 | } |
habiburrahman | 3:afd2bb1331a4 | 111 | } |
habiburrahman | 3:afd2bb1331a4 | 112 | |
habiburrahman | 3:afd2bb1331a4 | 113 | int b1cnt=0, b2cnt=0,b3cnt=0; |
habiburrahman | 3:afd2bb1331a4 | 114 | |
habiburrahman | 4:8c94c3ee8a3a | 115 | |
habiburrahman | 4:8c94c3ee8a3a | 116 | //below are the callback functions for the buttons and feeders |
habiburrahman | 4:8c94c3ee8a3a | 117 | |
habiburrahman | 4:8c94c3ee8a3a | 118 | //callback when button1 is pressed |
habiburrahman | 3:afd2bb1331a4 | 119 | void button1_callback(){ |
habiburrahman | 4:8c94c3ee8a3a | 120 | b1cnt++;//keeps count of number of presses |
habiburrahman | 3:afd2bb1331a4 | 121 | button1.update_flag = 0; |
habiburrahman | 0:122b5c3cbf4d | 122 | } |
habiburrahman | 0:122b5c3cbf4d | 123 | |
habiburrahman | 4:8c94c3ee8a3a | 124 | //callback when button2 is pressed |
habiburrahman | 3:afd2bb1331a4 | 125 | void button2_callback(){ |
habiburrahman | 4:8c94c3ee8a3a | 126 | b2cnt++;//keeps count of number of presses |
habiburrahman | 3:afd2bb1331a4 | 127 | button2.update_flag = 0; |
habiburrahman | 3:afd2bb1331a4 | 128 | } |
habiburrahman | 3:afd2bb1331a4 | 129 | |
habiburrahman | 4:8c94c3ee8a3a | 130 | //callback when button3 is pressed |
habiburrahman | 3:afd2bb1331a4 | 131 | void button3_callback(){ |
habiburrahman | 4:8c94c3ee8a3a | 132 | b3cnt++;//keeps count of number of presses |
habiburrahman | 3:afd2bb1331a4 | 133 | button3.update_flag = 0; |
habiburrahman | 3:afd2bb1331a4 | 134 | } |
habiburrahman | 0:122b5c3cbf4d | 135 | |
habiburrahman | 4:8c94c3ee8a3a | 136 | //callback on feeder1 update |
habiburrahman | 3:afd2bb1331a4 | 137 | void hFeeder1_callback(){ |
habiburrahman | 4:8c94c3ee8a3a | 138 | |
habiburrahman | 3:afd2bb1331a4 | 139 | hFeed1.update_flag = 0; |
habiburrahman | 3:afd2bb1331a4 | 140 | } |
habiburrahman | 0:122b5c3cbf4d | 141 | |
habiburrahman | 4:8c94c3ee8a3a | 142 | //callback on feeder2 update |
habiburrahman | 3:afd2bb1331a4 | 143 | void hFeeder2_callback(){ |
habiburrahman | 4:8c94c3ee8a3a | 144 | |
habiburrahman | 4:8c94c3ee8a3a | 145 | |
habiburrahman | 3:afd2bb1331a4 | 146 | hFeed2.update_flag = 0; |
habiburrahman | 3:afd2bb1331a4 | 147 | } |
habiburrahman | 0:122b5c3cbf4d | 148 | |
habiburrahman | 1:4f356fb65677 | 149 | |
habiburrahman | 1:4f356fb65677 | 150 | |
habiburrahman | 1:4f356fb65677 | 151 | |
habiburrahman | 3:afd2bb1331a4 | 152 | int main(){ |
habiburrahman | 3:afd2bb1331a4 | 153 | |
habiburrahman | 3:afd2bb1331a4 | 154 | uint8_t status; |
habiburrahman | 3:afd2bb1331a4 | 155 | |
habiburrahman | 4:8c94c3ee8a3a | 156 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"WOLLONGONG UNIVERSITY", CENTER_MODE); |
habiburrahman | 3:afd2bb1331a4 | 157 | wait(1); |
habiburrahman | 3:afd2bb1331a4 | 158 | |
habiburrahman | 0:122b5c3cbf4d | 159 | status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); |
habiburrahman | 0:122b5c3cbf4d | 160 | if (status != TS_OK) { |
habiburrahman | 0:122b5c3cbf4d | 161 | lcd.Clear(LCD_COLOR_RED); |
habiburrahman | 0:122b5c3cbf4d | 162 | lcd.SetBackColor(LCD_COLOR_RED); |
habiburrahman | 0:122b5c3cbf4d | 163 | lcd.SetTextColor(LCD_COLOR_WHITE); |
habiburrahman | 0:122b5c3cbf4d | 164 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE); |
habiburrahman | 0:122b5c3cbf4d | 165 | } else { |
habiburrahman | 0:122b5c3cbf4d | 166 | lcd.Clear(LCD_COLOR_BLUE); |
habiburrahman | 0:122b5c3cbf4d | 167 | lcd.SetBackColor(LCD_COLOR_BLUE); |
habiburrahman | 0:122b5c3cbf4d | 168 | lcd.SetTextColor(LCD_COLOR_WHITE); |
habiburrahman | 0:122b5c3cbf4d | 169 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE); |
habiburrahman | 0:122b5c3cbf4d | 170 | } |
habiburrahman | 0:122b5c3cbf4d | 171 | |
habiburrahman | 0:122b5c3cbf4d | 172 | lcd.SetBackColor(LCD_COLOR_YELLOW); |
habiburrahman | 0:122b5c3cbf4d | 173 | lcd.SetTextColor(LCD_COLOR_RED); |
habiburrahman | 0:122b5c3cbf4d | 174 | |
habiburrahman | 0:122b5c3cbf4d | 175 | lcd.Clear(LCD_COLOR_WHITE); |
habiburrahman | 0:122b5c3cbf4d | 176 | |
habiburrahman | 0:122b5c3cbf4d | 177 | |
habiburrahman | 0:122b5c3cbf4d | 178 | lcd.SetTextColor(LCD_COLOR_RED); |
habiburrahman | 3:afd2bb1331a4 | 179 | lcd.FillRect(but1pos.x, but1pos.y, but1pos.width, but1pos.height); |
habiburrahman | 3:afd2bb1331a4 | 180 | lcd.FillRect(but2pos.x, but2pos.y, but2pos.width, but2pos.height); |
habiburrahman | 3:afd2bb1331a4 | 181 | lcd.FillRect(but3pos.x, but3pos.y, but3pos.width, but3pos.height); |
habiburrahman | 0:122b5c3cbf4d | 182 | |
habiburrahman | 3:afd2bb1331a4 | 183 | lcd.FillRect(hFeed1pos.x, hFeed1pos.y, hFeed1pos.width, hFeed1pos.height); |
habiburrahman | 3:afd2bb1331a4 | 184 | lcd.FillRect(hFeed2pos.x, hFeed2pos.y, hFeed2pos.width, hFeed2pos.height); |
habiburrahman | 0:122b5c3cbf4d | 185 | |
habiburrahman | 0:122b5c3cbf4d | 186 | wait(1); |
habiburrahman | 0:122b5c3cbf4d | 187 | |
habiburrahman | 3:afd2bb1331a4 | 188 | |
habiburrahman | 0:122b5c3cbf4d | 189 | while(1){ |
habiburrahman | 0:122b5c3cbf4d | 190 | |
habiburrahman | 3:afd2bb1331a4 | 191 | ts.ResetTouchData(&TS_State); |
habiburrahman | 0:122b5c3cbf4d | 192 | ts.GetState(&TS_State); |
habiburrahman | 3:afd2bb1331a4 | 193 | //if (TS_State.touchDetected) |
habiburrahman | 3:afd2bb1331a4 | 194 | { |
habiburrahman | 3:afd2bb1331a4 | 195 | h_feeder(&hFeed1, &TS_State); |
habiburrahman | 3:afd2bb1331a4 | 196 | h_feeder(&hFeed2, &TS_State); |
habiburrahman | 3:afd2bb1331a4 | 197 | button(&button1, &TS_State); |
habiburrahman | 3:afd2bb1331a4 | 198 | button(&button2, &TS_State); |
habiburrahman | 3:afd2bb1331a4 | 199 | button(&button3, &TS_State); |
habiburrahman | 0:122b5c3cbf4d | 200 | |
habiburrahman | 0:122b5c3cbf4d | 201 | } |
habiburrahman | 0:122b5c3cbf4d | 202 | |
habiburrahman | 3:afd2bb1331a4 | 203 | if(hFeed1.update_flag)hFeeder1_callback(); |
habiburrahman | 3:afd2bb1331a4 | 204 | if(hFeed2.update_flag)hFeeder2_callback(); |
habiburrahman | 3:afd2bb1331a4 | 205 | if(button1.update_flag) button1_callback(); |
habiburrahman | 3:afd2bb1331a4 | 206 | if(button2.update_flag) button2_callback(); |
habiburrahman | 3:afd2bb1331a4 | 207 | if(button3.update_flag) button3_callback(); |
habiburrahman | 0:122b5c3cbf4d | 208 | |
habiburrahman | 4:8c94c3ee8a3a | 209 | printf("GUI values are \t\t%d,%d,%d\t%d,%d\t(%d,%d)\r\n", b1cnt, b2cnt,b3cnt,hFeed1.value, hFeed2.value,TS_State.touchX[0],TS_State.touchY[0]); |
habiburrahman | 3:afd2bb1331a4 | 210 | //printf("feeder values are (%d,%d) %f,%f,%f %d,%d\r\n", TS_State.touchX[0],TS_State.touchY[0],button1.depressTime.read(), button2.depressTime.read(),button3.depressTime.read(),hFeed1.value, hFeed2.value); |
habiburrahman | 0:122b5c3cbf4d | 211 | |
habiburrahman | 0:122b5c3cbf4d | 212 | } |
habiburrahman | 0:122b5c3cbf4d | 213 | } |
habiburrahman | 1:4f356fb65677 | 214 | |
habiburrahman | 1:4f356fb65677 | 215 | |
habiburrahman | 3:afd2bb1331a4 | 216 | |
habiburrahman | 1:4f356fb65677 | 217 | ///////////////////////////////////////////////////////////////////// |
habiburrahman | 1:4f356fb65677 | 218 | //ACCELEROMETER TEST |
habiburrahman | 1:4f356fb65677 | 219 | |
habiburrahman | 1:4f356fb65677 | 220 | #include "ADXL345.h" |
habiburrahman | 1:4f356fb65677 | 221 | |
habiburrahman | 1:4f356fb65677 | 222 | ADXL345 accelerometer(D11,D12,D13,D10); |
habiburrahman | 1:4f356fb65677 | 223 | Serial pc(USBTX, USBRX); |
habiburrahman | 1:4f356fb65677 | 224 | |
habiburrahman | 3:afd2bb1331a4 | 225 | int main2() { |
habiburrahman | 1:4f356fb65677 | 226 | |
habiburrahman | 1:4f356fb65677 | 227 | int readings[3] = {0, 0, 0}; |
habiburrahman | 1:4f356fb65677 | 228 | |
habiburrahman | 1:4f356fb65677 | 229 | pc.printf("Starting ADXL345 test...\n"); |
habiburrahman | 1:4f356fb65677 | 230 | pc.printf("Device ID is: 0x%02x\n", accelerometer.getDevId()); |
habiburrahman | 1:4f356fb65677 | 231 | |
habiburrahman | 1:4f356fb65677 | 232 | //Go into standby mode to configure the device. |
habiburrahman | 1:4f356fb65677 | 233 | accelerometer.setPowerControl(0x00); |
habiburrahman | 1:4f356fb65677 | 234 | |
habiburrahman | 1:4f356fb65677 | 235 | //Full resolution, +/-16g, 4mg/LSB. |
habiburrahman | 1:4f356fb65677 | 236 | accelerometer.setDataFormatControl(0x0B); |
habiburrahman | 1:4f356fb65677 | 237 | |
habiburrahman | 1:4f356fb65677 | 238 | //3.2kHz data rate. |
habiburrahman | 1:4f356fb65677 | 239 | accelerometer.setDataRate(ADXL345_3200HZ); |
habiburrahman | 1:4f356fb65677 | 240 | |
habiburrahman | 1:4f356fb65677 | 241 | //Measurement mode. |
habiburrahman | 1:4f356fb65677 | 242 | accelerometer.setPowerControl(0x08); |
habiburrahman | 1:4f356fb65677 | 243 | |
habiburrahman | 1:4f356fb65677 | 244 | while (1) { |
habiburrahman | 1:4f356fb65677 | 245 | |
habiburrahman | 1:4f356fb65677 | 246 | wait(0.1); |
habiburrahman | 1:4f356fb65677 | 247 | |
habiburrahman | 1:4f356fb65677 | 248 | accelerometer.getOutput(readings); |
habiburrahman | 1:4f356fb65677 | 249 | |
habiburrahman | 1:4f356fb65677 | 250 | //13-bit, sign extended values. |
habiburrahman | 1:4f356fb65677 | 251 | pc.printf("%i, %i, %i\n", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]); |
habiburrahman | 1:4f356fb65677 | 252 | |
habiburrahman | 1:4f356fb65677 | 253 | } |
habiburrahman | 1:4f356fb65677 | 254 | |
habiburrahman | 1:4f356fb65677 | 255 | } |
habiburrahman | 1:4f356fb65677 | 256 | |
habiburrahman | 1:4f356fb65677 | 257 | |
habiburrahman | 1:4f356fb65677 | 258 | |
habiburrahman | 1:4f356fb65677 | 259 | |
habiburrahman | 0:122b5c3cbf4d | 260 |