Thundersoft
/
IKS01A2_for_TT_Mxx
Creating a project about IKS10A2 for TT_Mxx
main.cpp@1:28de8dff2317, 2019-04-26 (annotated)
- Committer:
- ThunderSoft
- Date:
- Fri Apr 26 09:51:19 2019 +0000
- Revision:
- 1:28de8dff2317
- Parent:
- 0:69ddd5bce0a0
"Update the mbed-os code to support TT_M4G9"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThunderSoft | 0:69ddd5bce0a0 | 1 | #include "mbed.h" |
ThunderSoft | 0:69ddd5bce0a0 | 2 | #include "IKS01A2.h" |
ThunderSoft | 0:69ddd5bce0a0 | 3 | |
ThunderSoft | 0:69ddd5bce0a0 | 4 | |
ThunderSoft | 0:69ddd5bce0a0 | 5 | |
ThunderSoft | 0:69ddd5bce0a0 | 6 | |
ThunderSoft | 0:69ddd5bce0a0 | 7 | |
ThunderSoft | 0:69ddd5bce0a0 | 8 | |
ThunderSoft | 0:69ddd5bce0a0 | 9 | #ifdef TEST_LCD |
ThunderSoft | 0:69ddd5bce0a0 | 10 | LCD tft(LCD_SPI_CS,LCD_SPI_DC, LCD_MOSI_PIN, LCD_MISO_PIN, LCD_SPI_CL_PIN,LCD_BL_PIN); |
ThunderSoft | 0:69ddd5bce0a0 | 11 | #else |
ThunderSoft | 0:69ddd5bce0a0 | 12 | #define LCD int |
ThunderSoft | 0:69ddd5bce0a0 | 13 | LCD tft; |
ThunderSoft | 0:69ddd5bce0a0 | 14 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 15 | |
ThunderSoft | 0:69ddd5bce0a0 | 16 | |
ThunderSoft | 0:69ddd5bce0a0 | 17 | #if __TT_M3HQ__ |
ThunderSoft | 0:69ddd5bce0a0 | 18 | #define DISPLAY_TMPM_STRING "Welcome to Thundersoft TT_M3HQ" |
ThunderSoft | 0:69ddd5bce0a0 | 19 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 20 | |
ThunderSoft | 0:69ddd5bce0a0 | 21 | |
ThunderSoft | 0:69ddd5bce0a0 | 22 | #if __TT_M4G9__ |
ThunderSoft | 0:69ddd5bce0a0 | 23 | #define DISPLAY_TMPM_STRING "Welcome to Thundersoft TT_M4G9" |
ThunderSoft | 0:69ddd5bce0a0 | 24 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 25 | |
ThunderSoft | 0:69ddd5bce0a0 | 26 | |
ThunderSoft | 0:69ddd5bce0a0 | 27 | /*macros for ISK01A2 shiled board*/ |
ThunderSoft | 0:69ddd5bce0a0 | 28 | #define DISPLAY_LSM6DSL_ID_STRING "LSM6DSL ID:" |
ThunderSoft | 0:69ddd5bce0a0 | 29 | #define DISPLAY_LSM6DSL_ID_HIGHT 16 |
ThunderSoft | 0:69ddd5bce0a0 | 30 | #define DISPLAY_LSM303ACC_ID_STRING "LSMACC ID:" |
ThunderSoft | 0:69ddd5bce0a0 | 31 | #define DISPLAY_LSM303ACC_ID_HIGHT 32 |
ThunderSoft | 0:69ddd5bce0a0 | 32 | #define DISPLAY_LSM303MAG_ID_STRING "LSMMAG ID:" |
ThunderSoft | 0:69ddd5bce0a0 | 33 | #define DISPLAY_LSM303MAG_ID_HIGHT 48 |
ThunderSoft | 0:69ddd5bce0a0 | 34 | #define DISPLAY_HTS221_ID_STRING "HTS221 ID:" |
ThunderSoft | 0:69ddd5bce0a0 | 35 | #define DISPLAY_HTS221_ID_HIGHT 64 |
ThunderSoft | 0:69ddd5bce0a0 | 36 | #define DISPLAY_LPS22_ID_STRING "LPS22 ID:" |
ThunderSoft | 0:69ddd5bce0a0 | 37 | #define DISPLAY_LPS22_ID_HIGHT 80 |
ThunderSoft | 0:69ddd5bce0a0 | 38 | #define DISPLAY_LSM6DSL_ACC_VALUE_STRING "LSM6DSL X Axes:" |
ThunderSoft | 0:69ddd5bce0a0 | 39 | #define DISPLAY_LSM6DSL_ACC_VALUE_STRING_HIGHT 96 |
ThunderSoft | 0:69ddd5bce0a0 | 40 | #define DISPLAY_LSM6DSL_ACC_VALUE_HIGHT (DISPLAY_LSM6DSL_ACC_VALUE_STRING_HIGHT + FONT_CHAR_HEIGHT) |
ThunderSoft | 0:69ddd5bce0a0 | 41 | #define DISPLAY_LSM6DSL_MAG_VALUE_STRING "LSM6DSL G Axes:" |
ThunderSoft | 0:69ddd5bce0a0 | 42 | #define DISPLAY_LSM6DSL_MAG_VALUE_STRING_HIGHT 128 |
ThunderSoft | 0:69ddd5bce0a0 | 43 | #define DISPLAY_LSM6DSL_MAG_VALUE_HIGHT (DISPLAY_LSM6DSL_MAG_VALUE_STRING_HIGHT + FONT_CHAR_HEIGHT) |
ThunderSoft | 0:69ddd5bce0a0 | 44 | #define DISPLAY_LSM303AGR_ACC_VALUE_STRING "LSM303AGR:" |
ThunderSoft | 0:69ddd5bce0a0 | 45 | #define DISPLAY_LSM303AGR_ACC_VALUE_STRING_HIGH 160 |
ThunderSoft | 0:69ddd5bce0a0 | 46 | #define DISPLAY_LSM303AGR_ACC_VALUE_HIGH (DISPLAY_LSM303AGR_ACC_VALUE_STRING_HIGH + FONT_CHAR_HEIGHT) |
ThunderSoft | 0:69ddd5bce0a0 | 47 | #define DISPLAY_LSM303MAG_VALUE_STRING "LSM303MAG:" |
ThunderSoft | 0:69ddd5bce0a0 | 48 | #define DISPLAY_LSM303MAG_VALUE_STRING_HIGH 192 |
ThunderSoft | 0:69ddd5bce0a0 | 49 | #define DISPLAY_LSM303MAG_VALUE_HIGH (DISPLAY_LSM303MAG_VALUE_STRING_HIGH + FONT_CHAR_HEIGHT) |
ThunderSoft | 0:69ddd5bce0a0 | 50 | #define DISPLAY_HTS221_VALUE_STRING "HTS221:" |
ThunderSoft | 0:69ddd5bce0a0 | 51 | #define DISPLAY_HTS221_VALUE_STRING_HIGH (DISPLAY_LSM303MAG_VALUE_HIGH + FONT_CHAR_HEIGHT) |
ThunderSoft | 0:69ddd5bce0a0 | 52 | #define DISPLAY_HTS221_VALUE_HIGH (DISPLAY_HTS221_VALUE_STRING_HIGH + FONT_CHAR_HEIGHT) |
ThunderSoft | 0:69ddd5bce0a0 | 53 | #define DISPLAY_LPS22HB_VALUE_STRING "LPS22HB:" |
ThunderSoft | 0:69ddd5bce0a0 | 54 | #define DISPLAY_LPS22HB_VALUE_STRING_HIGH (DISPLAY_HTS221_VALUE_HIGH + FONT_CHAR_HEIGHT) |
ThunderSoft | 0:69ddd5bce0a0 | 55 | #define DISPLAY_LPS22HB_VALUE_HIGH (DISPLAY_LPS22HB_VALUE_STRING_HIGH + FONT_CHAR_HEIGHT) |
ThunderSoft | 0:69ddd5bce0a0 | 56 | |
ThunderSoft | 0:69ddd5bce0a0 | 57 | |
ThunderSoft | 0:69ddd5bce0a0 | 58 | |
ThunderSoft | 0:69ddd5bce0a0 | 59 | |
ThunderSoft | 0:69ddd5bce0a0 | 60 | static void displayForIKS01A2(LCD &lcd,IKS01A2 &iks102) |
ThunderSoft | 0:69ddd5bce0a0 | 61 | { |
ThunderSoft | 0:69ddd5bce0a0 | 62 | #ifdef TEST_LCD |
ThunderSoft | 0:69ddd5bce0a0 | 63 | char temp_buffer[5]; |
ThunderSoft | 0:69ddd5bce0a0 | 64 | temp_buffer[4] = '\0'; |
ThunderSoft | 0:69ddd5bce0a0 | 65 | lcd.drawString(0,0,DISPLAY_TMPM_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 66 | |
ThunderSoft | 0:69ddd5bce0a0 | 67 | lcd.drawString(0,DISPLAY_LSM6DSL_ID_HIGHT,DISPLAY_LSM6DSL_ID_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 68 | translateBinaryToBCD(temp_buffer,iks102.getIdLSM6DSL()); |
ThunderSoft | 0:69ddd5bce0a0 | 69 | lcd.drawString((sizeof(DISPLAY_LSM6DSL_ID_STRING) - 1) * FONT_CHAR_WIDTH,DISPLAY_LSM6DSL_ID_HIGHT,(const char *)temp_buffer,BLACK); |
ThunderSoft | 0:69ddd5bce0a0 | 70 | |
ThunderSoft | 0:69ddd5bce0a0 | 71 | lcd.drawString(0,DISPLAY_LSM303ACC_ID_HIGHT,DISPLAY_LSM303ACC_ID_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 72 | translateBinaryToBCD(temp_buffer,iks102.getIdLSM303AGR()); |
ThunderSoft | 0:69ddd5bce0a0 | 73 | lcd.drawString((sizeof(DISPLAY_LSM303ACC_ID_STRING) - 1) * FONT_CHAR_WIDTH,DISPLAY_LSM303ACC_ID_HIGHT,(const char *)temp_buffer,BLACK); |
ThunderSoft | 0:69ddd5bce0a0 | 74 | |
ThunderSoft | 0:69ddd5bce0a0 | 75 | lcd.drawString(0,DISPLAY_LSM303MAG_ID_HIGHT,DISPLAY_LSM303MAG_ID_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 76 | translateBinaryToBCD(temp_buffer,iks102.getIdLSM303MAG()); |
ThunderSoft | 0:69ddd5bce0a0 | 77 | lcd.drawString((sizeof(DISPLAY_LSM303MAG_ID_STRING) - 1) * FONT_CHAR_WIDTH,DISPLAY_LSM303MAG_ID_HIGHT,(const char *)temp_buffer,BLACK); |
ThunderSoft | 0:69ddd5bce0a0 | 78 | |
ThunderSoft | 0:69ddd5bce0a0 | 79 | lcd.drawString(0,DISPLAY_HTS221_ID_HIGHT,DISPLAY_HTS221_ID_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 80 | translateBinaryToBCD(temp_buffer,iks102.getIdHTS221()); |
ThunderSoft | 0:69ddd5bce0a0 | 81 | lcd.drawString((sizeof(DISPLAY_HTS221_ID_STRING) - 1) * FONT_CHAR_WIDTH,DISPLAY_HTS221_ID_HIGHT,(const char *)temp_buffer,BLACK); |
ThunderSoft | 0:69ddd5bce0a0 | 82 | |
ThunderSoft | 0:69ddd5bce0a0 | 83 | lcd.drawString(0,DISPLAY_LPS22_ID_HIGHT,DISPLAY_LPS22_ID_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 84 | translateBinaryToBCD(temp_buffer,iks102.getIdLPS22HB()); |
ThunderSoft | 0:69ddd5bce0a0 | 85 | lcd.drawString((sizeof(DISPLAY_LPS22_ID_STRING) - 1) * FONT_CHAR_WIDTH,DISPLAY_LPS22_ID_HIGHT,(const char *)temp_buffer,BLACK); |
ThunderSoft | 0:69ddd5bce0a0 | 86 | /*Set LSM6DSL for LCD string*/ |
ThunderSoft | 0:69ddd5bce0a0 | 87 | lcd.drawString(0,DISPLAY_LSM6DSL_ACC_VALUE_STRING_HIGHT,DISPLAY_LSM6DSL_ACC_VALUE_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 88 | lcd.drawString(0,DISPLAY_LSM6DSL_MAG_VALUE_STRING_HIGHT,DISPLAY_LSM6DSL_MAG_VALUE_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 89 | |
ThunderSoft | 0:69ddd5bce0a0 | 90 | lcd.drawString(0,DISPLAY_LSM303AGR_ACC_VALUE_STRING_HIGH,DISPLAY_LSM303AGR_ACC_VALUE_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 91 | lcd.drawString(0,DISPLAY_LSM303MAG_VALUE_STRING_HIGH,DISPLAY_LSM303MAG_VALUE_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 92 | lcd.drawString(0,DISPLAY_HTS221_VALUE_STRING_HIGH,DISPLAY_HTS221_VALUE_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 93 | lcd.drawString(0,DISPLAY_LPS22HB_VALUE_STRING_HIGH,DISPLAY_LPS22HB_VALUE_STRING,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 94 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 95 | } |
ThunderSoft | 0:69ddd5bce0a0 | 96 | |
ThunderSoft | 0:69ddd5bce0a0 | 97 | static void handleLCDForIKS102(LCD &lcd,IKS01A2 &iks102) |
ThunderSoft | 0:69ddd5bce0a0 | 98 | { |
ThunderSoft | 0:69ddd5bce0a0 | 99 | int32_t accelerometer[3]; |
ThunderSoft | 0:69ddd5bce0a0 | 100 | char temp_buffer[50]; |
ThunderSoft | 0:69ddd5bce0a0 | 101 | float humidity,temperature,pressure; |
ThunderSoft | 0:69ddd5bce0a0 | 102 | //display for IKS102 |
ThunderSoft | 0:69ddd5bce0a0 | 103 | //display Img |
ThunderSoft | 0:69ddd5bce0a0 | 104 | while(1) |
ThunderSoft | 0:69ddd5bce0a0 | 105 | { |
ThunderSoft | 0:69ddd5bce0a0 | 106 | /*Display LSM6DSL ACC*/ |
ThunderSoft | 0:69ddd5bce0a0 | 107 | memset(temp_buffer,0,sizeof(temp_buffer)); |
ThunderSoft | 0:69ddd5bce0a0 | 108 | iks102.getXAxesLSM6DSL(accelerometer); |
ThunderSoft | 0:69ddd5bce0a0 | 109 | sprintf(temp_buffer,"%d,%d,%d",accelerometer[0],accelerometer[1],accelerometer[2]); |
ThunderSoft | 0:69ddd5bce0a0 | 110 | printf("LSM6DSL X Axes = %d , %d , %d\r\n",accelerometer[0],accelerometer[1],accelerometer[2]); |
ThunderSoft | 0:69ddd5bce0a0 | 111 | #ifdef TEST_LCD |
ThunderSoft | 0:69ddd5bce0a0 | 112 | lcd.drawString(0,DISPLAY_LSM6DSL_ACC_VALUE_HIGHT,temp_buffer,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 113 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 114 | |
ThunderSoft | 0:69ddd5bce0a0 | 115 | /*Display LSM6DSL MAG*/ |
ThunderSoft | 0:69ddd5bce0a0 | 116 | memset(temp_buffer,0,sizeof(temp_buffer)); |
ThunderSoft | 0:69ddd5bce0a0 | 117 | iks102.getGAxesLSM6DSL(accelerometer); |
ThunderSoft | 0:69ddd5bce0a0 | 118 | sprintf(temp_buffer,"%d,%d,%d",accelerometer[0],accelerometer[1],accelerometer[2]); |
ThunderSoft | 0:69ddd5bce0a0 | 119 | printf("LSM6DSL G Axes = %d , %d , %d\r\n",accelerometer[0],accelerometer[1],accelerometer[2]); |
ThunderSoft | 0:69ddd5bce0a0 | 120 | #ifdef TEST_LCD |
ThunderSoft | 0:69ddd5bce0a0 | 121 | lcd.drawString(0,DISPLAY_LSM6DSL_MAG_VALUE_HIGHT,temp_buffer,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 122 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 123 | |
ThunderSoft | 0:69ddd5bce0a0 | 124 | /*Display LSM303AGR_ACC*/ |
ThunderSoft | 0:69ddd5bce0a0 | 125 | memset(temp_buffer,0,sizeof(temp_buffer)); |
ThunderSoft | 0:69ddd5bce0a0 | 126 | iks102.getDataLSM303AGR(accelerometer); |
ThunderSoft | 0:69ddd5bce0a0 | 127 | sprintf(temp_buffer,"%d,%d,%d",accelerometer[0],accelerometer[1],accelerometer[2]); |
ThunderSoft | 0:69ddd5bce0a0 | 128 | printf("LSM303AGR [acc/mg] = %d , %d , %d\r\n",accelerometer[0],accelerometer[1],accelerometer[2]); |
ThunderSoft | 0:69ddd5bce0a0 | 129 | #ifdef TEST_LCD |
ThunderSoft | 0:69ddd5bce0a0 | 130 | lcd.drawString(0,DISPLAY_LSM303AGR_ACC_VALUE_HIGH,temp_buffer,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 131 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 132 | |
ThunderSoft | 0:69ddd5bce0a0 | 133 | /*Display LSM303AGR_MAG*/ |
ThunderSoft | 0:69ddd5bce0a0 | 134 | memset(temp_buffer,0,sizeof(temp_buffer)); |
ThunderSoft | 0:69ddd5bce0a0 | 135 | iks102.getDataLSM303MAG(accelerometer); |
ThunderSoft | 0:69ddd5bce0a0 | 136 | sprintf(temp_buffer,"%d,%d,%d",accelerometer[0],accelerometer[1],accelerometer[2]); |
ThunderSoft | 0:69ddd5bce0a0 | 137 | printf("LSM303MAG [mag/mgauss] = %d , %d , %d\r\n",accelerometer[0],accelerometer[1],accelerometer[2]); |
ThunderSoft | 0:69ddd5bce0a0 | 138 | #ifdef TEST_LCD |
ThunderSoft | 0:69ddd5bce0a0 | 139 | lcd.drawString(0,DISPLAY_LSM303MAG_VALUE_HIGH,temp_buffer,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 140 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 141 | |
ThunderSoft | 0:69ddd5bce0a0 | 142 | /*Display HTS221*/ |
ThunderSoft | 0:69ddd5bce0a0 | 143 | memset(temp_buffer,0,sizeof(temp_buffer)); |
ThunderSoft | 0:69ddd5bce0a0 | 144 | iks102.GetHumidity(&humidity); |
ThunderSoft | 0:69ddd5bce0a0 | 145 | sprintf(temp_buffer,"humidity %d,",(int)humidity); |
ThunderSoft | 0:69ddd5bce0a0 | 146 | iks102.GetTemperatureHTS221(&temperature); |
ThunderSoft | 0:69ddd5bce0a0 | 147 | sprintf(temp_buffer + strlen(temp_buffer),"temperature %d",(int)temperature); |
ThunderSoft | 0:69ddd5bce0a0 | 148 | printf("HTS221Sensor humidity = %f,temperature = %f \r\n",humidity,temperature); |
ThunderSoft | 0:69ddd5bce0a0 | 149 | #ifdef TEST_LCD |
ThunderSoft | 0:69ddd5bce0a0 | 150 | lcd.drawString(0,DISPLAY_HTS221_VALUE_HIGH,temp_buffer,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 151 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 152 | |
ThunderSoft | 0:69ddd5bce0a0 | 153 | /*Display LPS22HB*/ |
ThunderSoft | 0:69ddd5bce0a0 | 154 | memset(temp_buffer,0,sizeof(temp_buffer)); |
ThunderSoft | 0:69ddd5bce0a0 | 155 | iks102.GetPressure(&humidity); |
ThunderSoft | 0:69ddd5bce0a0 | 156 | sprintf(temp_buffer,"pressure %d,",(int)humidity); |
ThunderSoft | 0:69ddd5bce0a0 | 157 | iks102.GetTemperatureLPS22HB(&temperature); |
ThunderSoft | 0:69ddd5bce0a0 | 158 | sprintf(temp_buffer + strlen(temp_buffer),"temperature %d",(int)temperature); |
ThunderSoft | 0:69ddd5bce0a0 | 159 | printf("LPS22HBSensor pressure = %f, temperature = %f \r\n",pressure,temperature); |
ThunderSoft | 0:69ddd5bce0a0 | 160 | #ifdef TEST_LCD |
ThunderSoft | 0:69ddd5bce0a0 | 161 | lcd.drawString(0,DISPLAY_LPS22HB_VALUE_HIGH,temp_buffer,RED); |
ThunderSoft | 0:69ddd5bce0a0 | 162 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 163 | //add log |
ThunderSoft | 0:69ddd5bce0a0 | 164 | wait_ms(1000); |
ThunderSoft | 0:69ddd5bce0a0 | 165 | #ifdef TEST_LCD |
ThunderSoft | 0:69ddd5bce0a0 | 166 | lcd.clearScreenArea(0,DISPLAY_LSM6DSL_ACC_VALUE_HIGHT,WHITE); |
ThunderSoft | 0:69ddd5bce0a0 | 167 | lcd.clearScreenArea(0,DISPLAY_LSM6DSL_MAG_VALUE_HIGHT,WHITE); |
ThunderSoft | 0:69ddd5bce0a0 | 168 | lcd.clearScreenArea(0,DISPLAY_LSM303AGR_ACC_VALUE_HIGH,WHITE); |
ThunderSoft | 0:69ddd5bce0a0 | 169 | lcd.clearScreenArea(0,DISPLAY_LSM303MAG_VALUE_HIGH,WHITE); |
ThunderSoft | 0:69ddd5bce0a0 | 170 | lcd.clearScreenArea(0,DISPLAY_HTS221_VALUE_HIGH,WHITE); |
ThunderSoft | 0:69ddd5bce0a0 | 171 | lcd.clearScreenArea(0,DISPLAY_LPS22HB_VALUE_HIGH,WHITE); |
ThunderSoft | 0:69ddd5bce0a0 | 172 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 173 | } |
ThunderSoft | 0:69ddd5bce0a0 | 174 | } |
ThunderSoft | 0:69ddd5bce0a0 | 175 | |
ThunderSoft | 0:69ddd5bce0a0 | 176 | |
ThunderSoft | 0:69ddd5bce0a0 | 177 | |
ThunderSoft | 0:69ddd5bce0a0 | 178 | int main() |
ThunderSoft | 0:69ddd5bce0a0 | 179 | { |
ThunderSoft | 0:69ddd5bce0a0 | 180 | int32_t accelerometer[3]; |
ThunderSoft | 0:69ddd5bce0a0 | 181 | float humidity,temperature; |
ThunderSoft | 0:69ddd5bce0a0 | 182 | float pressure; |
ThunderSoft | 0:69ddd5bce0a0 | 183 | printf("%s\r\n",DISPLAY_TMPM_STRING); |
ThunderSoft | 0:69ddd5bce0a0 | 184 | I2C *i2c =new I2C(D14,D15); |
ThunderSoft | 0:69ddd5bce0a0 | 185 | LSM6DSLSensor *lsm = new LSM6DSLSensor(i2c,LSM6DSL_ACC_GYRO_I2C_ADDRESS_HIGH); |
ThunderSoft | 0:69ddd5bce0a0 | 186 | LSM303AGR_ACC_Sensor *Acc = new LSM303AGR_ACC_Sensor(i2c); |
ThunderSoft | 0:69ddd5bce0a0 | 187 | LSM303AGR_MAG_Sensor *Mag = new LSM303AGR_MAG_Sensor(i2c); |
ThunderSoft | 0:69ddd5bce0a0 | 188 | |
ThunderSoft | 0:69ddd5bce0a0 | 189 | HTS221Sensor *HumTemp = new HTS221Sensor (i2c); |
ThunderSoft | 0:69ddd5bce0a0 | 190 | LPS22HBSensor *PressTemp = new LPS22HBSensor(i2c); |
ThunderSoft | 0:69ddd5bce0a0 | 191 | uint8_t temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 192 | lsm->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 193 | // |
ThunderSoft | 0:69ddd5bce0a0 | 194 | lsm->Enable_X(); |
ThunderSoft | 0:69ddd5bce0a0 | 195 | lsm->Enable_G(); |
ThunderSoft | 0:69ddd5bce0a0 | 196 | // |
ThunderSoft | 0:69ddd5bce0a0 | 197 | Acc->Enable(); |
ThunderSoft | 0:69ddd5bce0a0 | 198 | Mag->Enable(); |
ThunderSoft | 0:69ddd5bce0a0 | 199 | |
ThunderSoft | 0:69ddd5bce0a0 | 200 | HumTemp->Enable(); |
ThunderSoft | 0:69ddd5bce0a0 | 201 | PressTemp->Enable(); |
ThunderSoft | 0:69ddd5bce0a0 | 202 | printf("LSM6DSLSensor ID = 0x%x \r\n",temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 203 | |
ThunderSoft | 0:69ddd5bce0a0 | 204 | Acc->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 205 | printf("LSM303AGR_ACC_Sensor ID = 0x%x \r\n",temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 206 | Mag->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 207 | printf("LSM303AGR_MAG_Sensor ID = 0x%x \r\n",temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 208 | HumTemp->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 209 | printf("HTS221Sensor ID = 0x%x \r\n",temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 210 | PressTemp->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 211 | printf("LPS22HBSensor ID = 0x%x \r\n",temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 212 | |
ThunderSoft | 0:69ddd5bce0a0 | 213 | IKS01A2 iks102(i2c); |
ThunderSoft | 0:69ddd5bce0a0 | 214 | #ifdef TEST_LCD |
ThunderSoft | 0:69ddd5bce0a0 | 215 | tft.init(); |
ThunderSoft | 0:69ddd5bce0a0 | 216 | #endif |
ThunderSoft | 0:69ddd5bce0a0 | 217 | displayForIKS01A2(tft,iks102); |
ThunderSoft | 0:69ddd5bce0a0 | 218 | handleLCDForIKS102(tft,iks102); |
ThunderSoft | 0:69ddd5bce0a0 | 219 | while(1) |
ThunderSoft | 0:69ddd5bce0a0 | 220 | { |
ThunderSoft | 0:69ddd5bce0a0 | 221 | } |
ThunderSoft | 0:69ddd5bce0a0 | 222 | |
ThunderSoft | 0:69ddd5bce0a0 | 223 | } |