static void cmd_read(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; if (argc != 1) { chprintf(chp, "Usage: read [raw|cooked]\r\n"); return; } while (chnGetTimeout((BaseChannel *)chp, 150) == Q_TIMEOUT) { if (!strcmp (argv[0], "raw")) { #if CHPRINTF_USE_ANSI_CODE chprintf(chp, "\033[2J\033[1;1H"); #endif accelerometerReadRaw(&LIS3DSHD1, rawdata); chprintf(chp, "LIS3DSH Accelerometer raw data...\r\n"); for(i = 0; i < LIS3DSH_NUMBER_OF_AXES; i++) { chprintf(chp, "%c-axis: %d\r\n", axisID[i], rawdata[i]); } } else if (!strcmp (argv[0], "cooked")) { #if CHPRINTF_USE_ANSI_CODE chprintf(chp, "\033[2J\033[1;1H"); #endif accelerometerReadCooked(&LIS3DSHD1, cookeddata); chprintf(chp, "LIS3DSH Accelerometer cooked data...\r\n"); for(i = 0; i < LIS3DSH_NUMBER_OF_AXES; i++) { chprintf(chp, "%c-axis: %.4f mg\r\n", axisID[i], cookeddata[i]); } } else { chprintf(chp, "Usage: read [raw|cooked]\r\n"); return; } } chprintf(chp, "Stopped\r\n"); }
static void cmd_read(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; if (argc != 2) { chprintf(chp, "Usage: read [acc|gyro|both] [raw|cooked]\r\n"); return; } while (chnGetTimeout((BaseChannel *)chp, 150) == Q_TIMEOUT) { if (!strcmp (argv[0], "acc")) { if (!strcmp (argv[1], "raw")) { #if CHPRINTF_USE_ANSI_CODE chprintf(chp, "\033[2J\033[1;1H"); #endif accelerometerReadRaw(&LSM6DS0D1, rawdata); chprintf(chp, "LSM6DS0 Accelerometer raw data...\r\n"); for(i = 0; i < LSM6DS0_ACC_NUMBER_OF_AXES; i++) { chprintf(chp, "%c-axis: %d\r\n", axisID[i], rawdata[i]); } } else if (!strcmp (argv[1], "cooked")) { #if CHPRINTF_USE_ANSI_CODE chprintf(chp, "\033[2J\033[1;1H"); #endif accelerometerReadCooked(&LSM6DS0D1, cookeddata); chprintf(chp, "LSM6DS0 Accelerometer cooked data...\r\n"); for(i = 0; i < LSM6DS0_ACC_NUMBER_OF_AXES; i++) { chprintf(chp, "%c-axis: %.4f mG\r\n", axisID[i], cookeddata[i]); } } else { chprintf(chp, "Usage: read [acc|gyro|both] [raw|cooked]\r\n"); return; } } else if (!strcmp (argv[0], "gyro")) { if (!strcmp (argv[1], "raw")) { #if CHPRINTF_USE_ANSI_CODE chprintf(chp, "\033[2J\033[1;1H"); #endif gyroscopeReadRaw(&LSM6DS0D1, rawdata); chprintf(chp, "LSM6DS0 Gyroscope raw data...\r\n"); for(i = 0; i < LSM6DS0_GYRO_NUMBER_OF_AXES; i++) { chprintf(chp, "%c-axis: %d\r\n", axisID[i], rawdata[i]); } } else if (!strcmp (argv[1], "cooked")) { #if CHPRINTF_USE_ANSI_CODE chprintf(chp, "\033[2J\033[1;1H"); #endif gyroscopeReadCooked(&LSM6DS0D1, cookeddata); chprintf(chp, "LSM6DS0 Gyroscope cooked data...\r\n"); for(i = 0; i < LSM6DS0_GYRO_NUMBER_OF_AXES; i++) { chprintf(chp, "%c-axis: %.4f DPS\r\n", axisID[i], cookeddata[i]); } } else { chprintf(chp, "Usage: read [acc|gyro|both] [raw|cooked]\r\n"); return; } } else if (!strcmp (argv[0], "both")) { if (!strcmp (argv[1], "raw")) { #if CHPRINTF_USE_ANSI_CODE chprintf(chp, "\033[2J\033[1;1H"); #endif sensorReadRaw(&LSM6DS0D1, rawdata); chprintf(chp, "LSM6DS0 Accelerometer raw data...\r\n"); for(i = 0; i < LSM6DS0_ACC_NUMBER_OF_AXES; i++) { chprintf(chp, "%c-axis: %d\r\n", axisID[i], rawdata[i]); } chprintf(chp, "LSM6DS0 Gyroscope raw data...\r\n"); for(i = 0; i < LSM6DS0_GYRO_NUMBER_OF_AXES; i++) { chprintf(chp, "%c-axis: %d\r\n", axisID[i], rawdata[i + LSM6DS0_ACC_NUMBER_OF_AXES]); } } else if (!strcmp (argv[1], "cooked")) { #if CHPRINTF_USE_ANSI_CODE chprintf(chp, "\033[2J\033[1;1H"); #endif sensorReadCooked(&LSM6DS0D1, cookeddata); chprintf(chp, "LSM6DS0 Accelerometer cooked data...\r\n"); for(i = 0; i < LSM6DS0_ACC_NUMBER_OF_AXES; i++) { chprintf(chp, "%c-axis: %.4f mG\r\n", axisID[i], cookeddata[i]); } chprintf(chp, "LSM6DS0 Gyroscope cooked data...\r\n"); for(i = 0; i < LSM6DS0_GYRO_NUMBER_OF_AXES; i++) { chprintf(chp, "%c-axis: %.4f DPS\r\n", axisID[i], cookeddata[i + LSM6DS0_ACC_NUMBER_OF_AXES]); } } else { chprintf(chp, "Usage: read [acc|gyro|both] [raw|cooked]\r\n"); return; } } else { chprintf(chp, "Usage: read [acc|gyro|both] [raw|cooked]\r\n"); return; } } chprintf(chp, "Stopped\r\n"); }