下雨和cube。
This commit is contained in:
@@ -699,11 +699,14 @@ double zoom = 1.0;
|
||||
float x_ref = 0.0, y_ref = 0.0, z_ref = 0.0;
|
||||
bool waiting_for_command = true;
|
||||
|
||||
int current_mode = 0;
|
||||
Modes current_mode = Modes::Rain;
|
||||
bool can_change_mode = true;
|
||||
|
||||
byte cube_size = 1;
|
||||
byte cube_step = 1;
|
||||
|
||||
bool rain_create_new = false;
|
||||
|
||||
void setup() {
|
||||
for (int i = 22; i < 46; i++) {
|
||||
pinMode(i, OUTPUT);
|
||||
@@ -767,7 +770,7 @@ void setup() {
|
||||
// Wait for z_ref to have value;
|
||||
while (SensorReader::angle.z == 0.0 || SensorReader::angle.y == 0.0 ||
|
||||
SensorReader::angle.x == 0.0) {
|
||||
Serial.println("Wait");
|
||||
Serial.println("");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -799,6 +802,27 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (can_change_mode) {
|
||||
if (analogRead(JOYSTICK_VRY) > 974) {
|
||||
current_mode = (enum Modes)(current_mode + 1) % 5;
|
||||
can_change_mode = false;
|
||||
Cube::clear();
|
||||
Serial.print("Changed to mode: ");
|
||||
Serial.println(display_mode_name(current_mode));
|
||||
}
|
||||
else if (analogRead(JOYSTICK_VRY) < 50) {
|
||||
current_mode = (enum Modes)(current_mode + 4) % 5;
|
||||
can_change_mode = false;
|
||||
Cube::clear();
|
||||
Serial.print("Changed to mode: ");
|
||||
Serial.println(display_mode_name(current_mode));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (analogRead(JOYSTICK_VRY) > 400 && analogRead(JOYSTICK_VRY) < 624) {
|
||||
can_change_mode = true;
|
||||
}
|
||||
}
|
||||
switch (current_mode) {
|
||||
case Modes::CalculateAndDraw:
|
||||
calculate_and_draw();
|
||||
@@ -857,7 +881,7 @@ void cube() {
|
||||
Cube::draw_line(4 + cube_size, 4 + cube_size, 3 - cube_size,
|
||||
2 * cube_size + 2, 2, 3);
|
||||
|
||||
delay(50);
|
||||
delay(75);
|
||||
cube_size += cube_step;
|
||||
if (cube_size >= 3) {
|
||||
cube_step = -1;
|
||||
@@ -868,7 +892,29 @@ void cube() {
|
||||
}
|
||||
|
||||
void rain() {
|
||||
return;
|
||||
for (int z = 0; z < 7; z++) {
|
||||
for (int x = 0; x < 8; x++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
int upper_state = Cube::get_status(x, y, z + 1);
|
||||
if (upper_state > 0) {
|
||||
Cube::set_status(x, y, z, upper_state);
|
||||
Cube::set_status(x, y, z + 1, upper_state - 1);
|
||||
}
|
||||
else {
|
||||
Cube::set_status(x, y, z, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rain_create_new) {
|
||||
int num = random(64);
|
||||
Cube::set_status(num / 8, num % 8, 7, 3);
|
||||
rain_create_new = false;
|
||||
}
|
||||
else {
|
||||
rain_create_new = true;
|
||||
}
|
||||
}
|
||||
|
||||
void clock() {
|
||||
@@ -1101,4 +1147,21 @@ void on_joystick_button() {
|
||||
Serial.println("Reset position.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String display_mode_name(Modes mode_name) {
|
||||
switch (mode_name) {
|
||||
case Modes::CalculateAndDraw:
|
||||
return String("Draw function graph");
|
||||
case Modes::Cube:
|
||||
return String("Cube");
|
||||
case Modes::Rain:
|
||||
return String("Rain");
|
||||
case Modes::Clock:
|
||||
return String("Clock");
|
||||
case Modes::Words:
|
||||
return String("Display Words");
|
||||
default:
|
||||
return String("Unknown");
|
||||
}
|
||||
}
|
||||
@@ -1,240 +1,74 @@
|
||||
#include "REG.h"
|
||||
#include "wit_c_sdk.h"
|
||||
|
||||
// #define ACC_UPDATE 0x01
|
||||
// #define GYRO_UPDATE 0x02
|
||||
// #define ANGLE_UPDATE 0x04
|
||||
// #define MAG_UPDATE 0x08
|
||||
// #define READ_UPDATE 0x80
|
||||
|
||||
// char s_cDataUpdate = 0;
|
||||
// const uint32_t c_uiBaud[8] = {0, 4800, 9600, 19200,
|
||||
// 38400, 57600, 115200, 230400};
|
||||
|
||||
// float fAcc[3], fGyro[3], fAngle[3];
|
||||
|
||||
// bool setup_ok = true;
|
||||
|
||||
// static void SensorUartSend(uint8_t *p_data, uint32_t uiSize);
|
||||
// static void SensorDataUpdate(uint32_t uiReg, uint32_t uiRegNum);
|
||||
// static void Delayms(uint16_t ucMs);
|
||||
// static void AutoScanSensor();
|
||||
|
||||
// void setup() {
|
||||
// Serial.begin(115200);
|
||||
// WitInit(WIT_PROTOCOL_NORMAL, 0x50);
|
||||
// WitSerialWriteRegister(SensorUartSend);
|
||||
// WitRegisterCallBack(SensorDataUpdate);
|
||||
// WitDelayMsRegister(Delayms);
|
||||
// AutoScanSensor();
|
||||
|
||||
// // Ensure the setting for the sensor is the default
|
||||
// if (WitSetBandwidth(BANDWIDTH_256HZ) != WIT_HAL_OK) {
|
||||
// Serial.print("Set Bandwidth Error\r\n");
|
||||
// setup_ok = false;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // if (WitSetUartBaud(WIT_BAUD_115200) != WIT_HAL_OK) {
|
||||
// // Serial.print("Set baud error\r\n");
|
||||
// // setup_ok = false;
|
||||
// // return;
|
||||
// // } else {
|
||||
// // Serial1.begin(115200);
|
||||
// // }
|
||||
|
||||
// if (WitSetOutputRate(RRATE_1HZ) != WIT_HAL_OK) {
|
||||
// Serial.print("Can't set report rate to 10Hz!\r\n");
|
||||
// setup_ok = false;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (WitSetContent(RSW_ACC | RSW_GYRO | RSW_ANGLE | RSW_MAG) != WIT_HAL_OK)
|
||||
// {
|
||||
// Serial.print("Set RSW Error\r\n");
|
||||
// setup_ok = false;
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// void loop() {
|
||||
// while (Serial1.available()) {
|
||||
// WitSerialDataIn(Serial1.read());
|
||||
// }
|
||||
|
||||
// // if (s_cDataUpdate) {
|
||||
// // for (int i = 0; i < 3; i++) {
|
||||
// // fAcc[i] = sReg[AX + i] / 32768.0f * 16.0f; // Unit: g(9.8m/s^2)
|
||||
// // fGyro[i] = sReg[GX + i] / 32768.0f * 2000.0f; // Unit: deg/s
|
||||
// // fAngle[i] = sReg[Roll + i] / 32768.0f * 180.0f; // Unit: deg
|
||||
// // }
|
||||
|
||||
// // if (s_cDataUpdate & ACC_UPDATE) {
|
||||
// // Serial.print("acc:");
|
||||
// // Serial.print(fAcc[0], 3);
|
||||
// // Serial.print(" ");
|
||||
// // Serial.print(fAcc[1], 3);
|
||||
// // Serial.print(" ");
|
||||
// // Serial.print(fAcc[2], 3);
|
||||
// // Serial.print("\r\n");
|
||||
// // s_cDataUpdate &= ~ACC_UPDATE;
|
||||
// // }
|
||||
// // if (s_cDataUpdate & GYRO_UPDATE) {
|
||||
// // Serial.print("gyro:");
|
||||
// // Serial.print(fGyro[0], 1);
|
||||
// // Serial.print(" ");
|
||||
// // Serial.print(fGyro[1], 1);
|
||||
// // Serial.print(" ");
|
||||
// // Serial.print(fGyro[2], 1);
|
||||
// // Serial.print("\r\n");
|
||||
// // s_cDataUpdate &= ~GYRO_UPDATE;
|
||||
// // }
|
||||
// // if (s_cDataUpdate & ANGLE_UPDATE) {
|
||||
// // Serial.print("angle:");
|
||||
// // Serial.print(fAngle[0], 3);
|
||||
// // Serial.print(" ");
|
||||
// // Serial.print(fAngle[1], 3);
|
||||
// // Serial.print(" ");
|
||||
// // Serial.print(fAngle[2], 3);
|
||||
// // Serial.print("\r\n");
|
||||
// // s_cDataUpdate &= ~ANGLE_UPDATE;
|
||||
// // }
|
||||
// // if (s_cDataUpdate & MAG_UPDATE) {
|
||||
// // Serial.print("mag:");
|
||||
// // Serial.print(sReg[HX]);
|
||||
// // Serial.print(" ");
|
||||
// // Serial.print(sReg[HY]);
|
||||
// // Serial.print(" ");
|
||||
// // Serial.print(sReg[HZ]);
|
||||
// // Serial.print("\r\n");
|
||||
// // s_cDataUpdate &= ~MAG_UPDATE;
|
||||
// // }
|
||||
// // s_cDataUpdate = 0;
|
||||
// // }
|
||||
// }
|
||||
|
||||
// static void SensorUartSend(uint8_t *p_data, uint32_t uiSize) {
|
||||
// Serial1.print("Sensor says: ");
|
||||
// Serial1.write(p_data, uiSize);
|
||||
// Serial1.flush();
|
||||
// };
|
||||
|
||||
// static void SensorDataUpdate(uint32_t uiReg, uint32_t uiRegNum) {
|
||||
// int i;
|
||||
// for (i = 0; i < uiRegNum; i++) {
|
||||
// switch (uiReg) {
|
||||
// case AZ:
|
||||
// s_cDataUpdate |= ACC_UPDATE;
|
||||
// break;
|
||||
// case GZ:
|
||||
// s_cDataUpdate |= GYRO_UPDATE;
|
||||
// break;
|
||||
// case HZ:
|
||||
// s_cDataUpdate |= MAG_UPDATE;
|
||||
// break;
|
||||
// case Yaw:
|
||||
// s_cDataUpdate |= ANGLE_UPDATE;
|
||||
// break;
|
||||
// default:
|
||||
// s_cDataUpdate |= READ_UPDATE;
|
||||
// break;
|
||||
// }
|
||||
// uiReg++;
|
||||
// }
|
||||
// Serial.println(s_cDataUpdate);
|
||||
// };
|
||||
|
||||
// static void Delayms(uint16_t ucMs) { delay(ucMs); }
|
||||
|
||||
// static void AutoScanSensor() {
|
||||
// int i, iRetry;
|
||||
|
||||
// for (i = 0; i < sizeof(c_uiBaud) / sizeof(c_uiBaud[0]); i++) {
|
||||
// Serial1.begin(c_uiBaud[i]);
|
||||
// Serial1.flush();
|
||||
// iRetry = 2;
|
||||
// s_cDataUpdate = 0;
|
||||
// do {
|
||||
// WitReadReg(AX, 3);
|
||||
// delay(200);
|
||||
// while (Serial1.available()) {
|
||||
// WitSerialDataIn(Serial1.read());
|
||||
// }
|
||||
// if (s_cDataUpdate != 0) {
|
||||
// Serial.print(c_uiBaud[i]);
|
||||
// Serial.print(" baud find sensor\r\n\r\n");
|
||||
// return;
|
||||
// }
|
||||
// iRetry--;
|
||||
// } while (iRetry);
|
||||
// }
|
||||
// Serial.print("can not find sensor\r\n");
|
||||
// Serial.print("please check your connection\r\n");
|
||||
// }
|
||||
|
||||
/*
|
||||
Test on MEGA 2560. use WT901CTTL sensor
|
||||
|
||||
WT901CTTL MEGA 2560a
|
||||
VCC <---> 5V/3.3V
|
||||
TX <---> 19(TX1)
|
||||
RX <---> 18(RX1)
|
||||
GND <---> GND
|
||||
*/
|
||||
|
||||
#define ACC_UPDATE 0x01
|
||||
#define GYRO_UPDATE 0x02
|
||||
#define ANGLE_UPDATE 0x04
|
||||
#define MAG_UPDATE 0x08
|
||||
#define READ_UPDATE 0x80
|
||||
static volatile char s_cDataUpdate = 0, s_cCmd = 0xff;
|
||||
|
||||
static void CmdProcess(void);
|
||||
static void AutoScanSensor(void);
|
||||
static void SensorUartSend(uint8_t *p_data, uint32_t uiSize);
|
||||
static void SensorDataUpdata(uint32_t uiReg, uint32_t uiRegNum);
|
||||
static void Delayms(uint16_t ucMs);
|
||||
char s_cDataUpdate = 0;
|
||||
const uint32_t c_uiBaud[8] = {0, 4800, 9600, 19200,
|
||||
38400, 57600, 115200, 230400};
|
||||
|
||||
int i;
|
||||
float fAcc[3], fGyro[3], fAngle[3];
|
||||
|
||||
bool setup_ok = true;
|
||||
|
||||
static void SensorUartSend(uint8_t *p_data, uint32_t uiSize);
|
||||
static void SensorDataUpdate(uint32_t uiReg, uint32_t uiRegNum);
|
||||
static void Delayms(uint16_t ucMs);
|
||||
static void AutoScanSensor();
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
WitInit(WIT_PROTOCOL_NORMAL, 0x50);
|
||||
WitSerialWriteRegister(SensorUartSend);
|
||||
WitRegisterCallBack(SensorDataUpdata);
|
||||
WitRegisterCallBack(SensorDataUpdate);
|
||||
WitDelayMsRegister(Delayms);
|
||||
AutoScanSensor();
|
||||
|
||||
if (WitStartAccCali() == WIT_HAL_OK) {
|
||||
Serial.print("Start Calibri");
|
||||
delay(1000);
|
||||
Serial.print("Stop calibri");
|
||||
WitStopAccCali();
|
||||
} else {
|
||||
Serial.print("Cannot start calibri acc\r\n");
|
||||
// Ensure the setting for the sensor is the default
|
||||
if (WitSetBandwidth(BANDWIDTH_256HZ) != WIT_HAL_OK) {
|
||||
Serial.print("Set Bandwidth Error\r\n");
|
||||
setup_ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (WitSetUartBaud(WIT_BAUD_9600) != WIT_HAL_OK)
|
||||
Serial.print("\r\nSet Baud Error\r\n");
|
||||
else {
|
||||
Serial1.begin(c_uiBaud[WIT_BAUD_9600]);
|
||||
Serial.print(" 115200 Baud rate modified successfully\r\n");
|
||||
// if (WitSetUartBaud(WIT_BAUD_115200) != WIT_HAL_OK) {
|
||||
// Serial.print("Set baud error\r\n");
|
||||
// setup_ok = false;
|
||||
// return;
|
||||
// } else {
|
||||
// Serial1.begin(115200);
|
||||
// }
|
||||
|
||||
if (WitSetOutputRate(RRATE_1HZ) != WIT_HAL_OK) {
|
||||
Serial.print("Can't set report rate to 10Hz!\r\n");
|
||||
setup_ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (WitSetContent(RSW_ACC | RSW_GYRO | RSW_ANGLE | RSW_MAG) != WIT_HAL_OK)
|
||||
{
|
||||
Serial.print("Set RSW Error\r\n");
|
||||
setup_ok = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
while (Serial1.available()) {
|
||||
WitSerialDataIn(Serial1.read());
|
||||
}
|
||||
|
||||
if (s_cDataUpdate) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
fAcc[i] = sReg[AX + i] / 32768.0f * 16.0f * 9.8f; // Unit: m/s^2
|
||||
fGyro[i] = sReg[GX + i] / 32768.0f * 2000.0f; // Unit: deg/s
|
||||
for (int i = 0; i < 3; i++) {
|
||||
fAcc[i] = sReg[AX + i] / 32768.0f * 16.0f; // Unit: g(9.8m/s^2)
|
||||
fGyro[i] = sReg[GX + i] / 32768.0f * 2000.0f; // Unit: deg/s
|
||||
fAngle[i] = sReg[Roll + i] / 32768.0f * 180.0f; // Unit: deg
|
||||
}
|
||||
Serial.print("Here");
|
||||
if (s_cDataUpdate & ACC_UPDATE) {
|
||||
Serial.print("acc:");
|
||||
Serial.print(fAcc[0], 3);
|
||||
@@ -282,9 +116,9 @@ void loop() {
|
||||
static void SensorUartSend(uint8_t *p_data, uint32_t uiSize) {
|
||||
Serial1.write(p_data, uiSize);
|
||||
Serial1.flush();
|
||||
}
|
||||
static void Delayms(uint16_t ucMs) { delay(ucMs); }
|
||||
static void SensorDataUpdata(uint32_t uiReg, uint32_t uiRegNum) {
|
||||
};
|
||||
|
||||
static void SensorDataUpdate(uint32_t uiReg, uint32_t uiRegNum) {
|
||||
int i;
|
||||
for (i = 0; i < uiRegNum; i++) {
|
||||
switch (uiReg) {
|
||||
@@ -306,9 +140,12 @@ static void SensorDataUpdata(uint32_t uiReg, uint32_t uiRegNum) {
|
||||
}
|
||||
uiReg++;
|
||||
}
|
||||
}
|
||||
// Serial.println(s_cDataUpdate);
|
||||
};
|
||||
|
||||
static void AutoScanSensor(void) {
|
||||
static void Delayms(uint16_t ucMs) { delay(ucMs); }
|
||||
|
||||
static void AutoScanSensor() {
|
||||
int i, iRetry;
|
||||
|
||||
for (i = 0; i < sizeof(c_uiBaud) / sizeof(c_uiBaud[0]); i++) {
|
||||
@@ -333,3 +170,165 @@ static void AutoScanSensor(void) {
|
||||
Serial.print("can not find sensor\r\n");
|
||||
Serial.print("please check your connection\r\n");
|
||||
}
|
||||
|
||||
/*
|
||||
Test on MEGA 2560. use WT901CTTL sensor
|
||||
|
||||
WT901CTTL MEGA 2560a
|
||||
VCC <---> 5V/3.3V
|
||||
TX <---> 19(TX1)
|
||||
RX <---> 18(RX1)
|
||||
GND <---> GND
|
||||
*/
|
||||
|
||||
// #define ACC_UPDATE 0x01
|
||||
// #define GYRO_UPDATE 0x02
|
||||
// #define ANGLE_UPDATE 0x04
|
||||
// #define MAG_UPDATE 0x08
|
||||
// #define READ_UPDATE 0x80
|
||||
// static volatile char s_cDataUpdate = 0, s_cCmd = 0xff;
|
||||
|
||||
// static void CmdProcess(void);
|
||||
// static void AutoScanSensor(void);
|
||||
// static void SensorUartSend(uint8_t *p_data, uint32_t uiSize);
|
||||
// static void SensorDataUpdata(uint32_t uiReg, uint32_t uiRegNum);
|
||||
// static void Delayms(uint16_t ucMs);
|
||||
// const uint32_t c_uiBaud[8] = {0, 4800, 9600, 19200,
|
||||
// 38400, 57600, 115200, 230400};
|
||||
|
||||
// int i;
|
||||
// float fAcc[3], fGyro[3], fAngle[3];
|
||||
|
||||
// void setup() {
|
||||
// // put your setup code here, to run once:
|
||||
// Serial.begin(115200);
|
||||
// WitInit(WIT_PROTOCOL_NORMAL, 0x50);
|
||||
// WitSerialWriteRegister(SensorUartSend);
|
||||
// WitRegisterCallBack(SensorDataUpdata);
|
||||
// WitDelayMsRegister(Delayms);
|
||||
// AutoScanSensor();
|
||||
|
||||
// // if (WitStartAccCali() == WIT_HAL_OK) {
|
||||
// // Serial.print("Start Calibri");
|
||||
// // delay(1000);
|
||||
// // Serial.print("Stop calibri");
|
||||
// // WitStopAccCali();
|
||||
// // } else {
|
||||
// // Serial.print("Cannot start calibri acc\r\n");
|
||||
// // }
|
||||
|
||||
// if (WitSetUartBaud(WIT_BAUD_9600) != WIT_HAL_OK)
|
||||
// Serial.print("\r\nSet Baud Error\r\n");
|
||||
// else {
|
||||
// Serial1.begin(c_uiBaud[WIT_BAUD_9600]);
|
||||
// Serial.print(" 9600 Baud rate modified successfully\r\n");
|
||||
// }
|
||||
// }
|
||||
// void loop() {
|
||||
// while (Serial1.available()) {
|
||||
// WitSerialDataIn(Serial1.read());
|
||||
// }
|
||||
// if (s_cDataUpdate) {
|
||||
// for (i = 0; i < 3; i++) {
|
||||
// fAcc[i] = sReg[AX + i] / 32768.0f * 16.0f * 9.8f; // Unit: m/s^2
|
||||
// fGyro[i] = sReg[GX + i] / 32768.0f * 2000.0f; // Unit: deg/s
|
||||
// fAngle[i] = sReg[Roll + i] / 32768.0f * 180.0f; // Unit: deg
|
||||
// }
|
||||
// if (s_cDataUpdate & ACC_UPDATE) {
|
||||
// Serial.print("acc:");
|
||||
// Serial.print(fAcc[0], 3);
|
||||
// Serial.print(" ");
|
||||
// Serial.print(fAcc[1], 3);
|
||||
// Serial.print(" ");
|
||||
// Serial.print(fAcc[2], 3);
|
||||
// Serial.print("\r\n");
|
||||
// s_cDataUpdate &= ~ACC_UPDATE;
|
||||
// }
|
||||
// if (s_cDataUpdate & GYRO_UPDATE) {
|
||||
// Serial.print("gyro:");
|
||||
// Serial.print(fGyro[0], 1);
|
||||
// Serial.print(" ");
|
||||
// Serial.print(fGyro[1], 1);
|
||||
// Serial.print(" ");
|
||||
// Serial.print(fGyro[2], 1);
|
||||
// Serial.print("\r\n");
|
||||
// s_cDataUpdate &= ~GYRO_UPDATE;
|
||||
// }
|
||||
// if (s_cDataUpdate & ANGLE_UPDATE) {
|
||||
// Serial.print("angle:");
|
||||
// Serial.print(fAngle[0], 3);
|
||||
// Serial.print(" ");
|
||||
// Serial.print(fAngle[1], 3);
|
||||
// Serial.print(" ");
|
||||
// Serial.print(fAngle[2], 3);
|
||||
// Serial.print("\r\n");
|
||||
// s_cDataUpdate &= ~ANGLE_UPDATE;
|
||||
// }
|
||||
// if (s_cDataUpdate & MAG_UPDATE) {
|
||||
// Serial.print("mag:");
|
||||
// Serial.print(sReg[HX]);
|
||||
// Serial.print(" ");
|
||||
// Serial.print(sReg[HY]);
|
||||
// Serial.print(" ");
|
||||
// Serial.print(sReg[HZ]);
|
||||
// Serial.print("\r\n");
|
||||
// s_cDataUpdate &= ~MAG_UPDATE;
|
||||
// }
|
||||
// s_cDataUpdate = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
// static void SensorUartSend(uint8_t *p_data, uint32_t uiSize) {
|
||||
// Serial1.write(p_data, uiSize);
|
||||
// Serial1.flush();
|
||||
// }
|
||||
// static void Delayms(uint16_t ucMs) { delay(ucMs); }
|
||||
// static void SensorDataUpdata(uint32_t uiReg, uint32_t uiRegNum) {
|
||||
// int i;
|
||||
// for (i = 0; i < uiRegNum; i++) {
|
||||
// switch (uiReg) {
|
||||
// case AZ:
|
||||
// s_cDataUpdate |= ACC_UPDATE;
|
||||
// break;
|
||||
// case GZ:
|
||||
// s_cDataUpdate |= GYRO_UPDATE;
|
||||
// break;
|
||||
// case HZ:
|
||||
// s_cDataUpdate |= MAG_UPDATE;
|
||||
// break;
|
||||
// case Yaw:
|
||||
// s_cDataUpdate |= ANGLE_UPDATE;
|
||||
// break;
|
||||
// default:
|
||||
// s_cDataUpdate |= READ_UPDATE;
|
||||
// break;
|
||||
// }
|
||||
// uiReg++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// static void AutoScanSensor(void) {
|
||||
// int i, iRetry;
|
||||
|
||||
// for (i = 0; i < sizeof(c_uiBaud) / sizeof(c_uiBaud[0]); i++) {
|
||||
// Serial1.begin(c_uiBaud[i]);
|
||||
// Serial1.flush();
|
||||
// iRetry = 2;
|
||||
// s_cDataUpdate = 0;
|
||||
// do {
|
||||
// WitReadReg(AX, 3);
|
||||
// delay(200);
|
||||
// while (Serial1.available()) {
|
||||
// WitSerialDataIn(Serial1.read());
|
||||
// }
|
||||
// if (s_cDataUpdate != 0) {
|
||||
// Serial.print(c_uiBaud[i]);
|
||||
// Serial.print(" baud find sensor\r\n\r\n");
|
||||
// return;
|
||||
// }
|
||||
// iRetry--;
|
||||
// } while (iRetry);
|
||||
// }
|
||||
// Serial.print("can not find sensor\r\n");
|
||||
// Serial.print("please check your connection\r\n");
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user