|
|
@ -19,6 +19,7 @@ uint8_t button10 = 0; |
|
|
|
// Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, -1);
|
|
|
|
// Initialize the OLED display using Wire library
|
|
|
|
SSD1306Wire display(0x3C, OLED_SDA, OLED_SCL, GEOMETRY_128_64, I2C_TWO, 700000); |
|
|
|
ADS1115 ADS(0x48, &Wire1); |
|
|
|
|
|
|
|
void setup() { |
|
|
|
Serial.begin(115200); |
|
|
@ -40,6 +41,7 @@ void setup() { |
|
|
|
i2c_status = true; |
|
|
|
} |
|
|
|
|
|
|
|
// Init Display
|
|
|
|
display.init(); |
|
|
|
display.setContrast(255); |
|
|
|
display.setTextAlignment(TEXT_ALIGN_LEFT); |
|
|
@ -47,6 +49,18 @@ void setup() { |
|
|
|
display.drawString(0, 16, "BigRC v1.0"); |
|
|
|
display.display(); |
|
|
|
|
|
|
|
// Init ADC
|
|
|
|
if(!ADS.begin(ADS1115_SCL, ADS1115_SDA)) { |
|
|
|
display.setFont(ArialMT_Plain_10); |
|
|
|
display.drawString(0, 0, "ADS1115 ERROR!"); |
|
|
|
display.display(); |
|
|
|
delay(5000); |
|
|
|
} |
|
|
|
//// ADS.setWireClock(100000);
|
|
|
|
ADS.setGain(1); // +- 4.096V
|
|
|
|
ADS.setDataRate(7); // 7 = Fastest
|
|
|
|
|
|
|
|
|
|
|
|
//// Wire.beginTransmission(I2C_DEVICE_MAX_ADDRESS_RANGE - 2);
|
|
|
|
|
|
|
|
// Preparing I/O
|
|
|
@ -114,15 +128,15 @@ void setup() { |
|
|
|
CPU_1 |
|
|
|
); |
|
|
|
|
|
|
|
xTaskCreatePinnedToCore( |
|
|
|
taskSystemStatus, |
|
|
|
"TaskSystemStatus", // Name of the process
|
|
|
|
8192, // This stack size can be checked & adjusted by reading the Stack Highwater
|
|
|
|
NULL, |
|
|
|
4, // Priority
|
|
|
|
NULL, |
|
|
|
CPU_1 |
|
|
|
); |
|
|
|
// xTaskCreatePinnedToCore(
|
|
|
|
// taskSystemStatus,
|
|
|
|
// "TaskSystemStatus", // Name of the process
|
|
|
|
// 8192, // This stack size can be checked & adjusted by reading the Stack Highwater
|
|
|
|
// NULL,
|
|
|
|
// 4, // Priority
|
|
|
|
// NULL,
|
|
|
|
// CPU_1
|
|
|
|
// );
|
|
|
|
|
|
|
|
xTaskCreatePinnedToCore( |
|
|
|
taskGimbal, |
|
|
@ -400,20 +414,24 @@ void taskGimbal(void *pvParameters) { |
|
|
|
// raw_throttle = analogRead(THROTTLE_PIN);
|
|
|
|
// throttle_steps = median_throttle(raw_throttle);
|
|
|
|
// Sampling throttle
|
|
|
|
throttle_steps = sampling(THROTTLE_POOL); |
|
|
|
// throttle_steps = sampling(THROTTLE_POOL);
|
|
|
|
throttle_steps = ADS.readADC(3); |
|
|
|
|
|
|
|
// raw_yaw = analogRead(YAW_PIN);
|
|
|
|
// yaw_steps = median_yaw(raw_yaw);
|
|
|
|
// Sampling yaw
|
|
|
|
yaw_steps = sampling(YAW_POOL); |
|
|
|
// yaw_steps = sampling(YAW_POOL);
|
|
|
|
yaw_steps = ADS.readADC(2); |
|
|
|
|
|
|
|
// raw_roll = analogRead(ROLL_PIN);
|
|
|
|
// roll_steps = median_roll(raw_roll);
|
|
|
|
roll_steps = sampling(ROLL_POOL); |
|
|
|
// roll_steps = sampling(ROLL_POOL);
|
|
|
|
roll_steps = ADS.readADC(1); |
|
|
|
|
|
|
|
// raw_pitch = analogRead(PITCH_PIN);
|
|
|
|
// $pitch_steps = median_pitch(raw_pitch);
|
|
|
|
pitch_steps = sampling(PITCH_POOL); |
|
|
|
// pitch_steps = sampling(PITCH_POOL);
|
|
|
|
pitch_steps = ADS.readADC(0); |
|
|
|
|
|
|
|
// profiling_end = micros();
|
|
|
|
|
|
|
@ -442,7 +460,7 @@ void taskCounter(void *pvParameters) { |
|
|
|
|
|
|
|
for(;;) { |
|
|
|
vTaskDelay(1); |
|
|
|
if((uint32_t)(millis() - last_update) > 1000) { |
|
|
|
if((uint32_t)(millis() - last_update) > 1001) { |
|
|
|
counter = counter_raw; |
|
|
|
counter_raw = 0; |
|
|
|
|
|
|
@ -985,8 +1003,12 @@ void display_info(void) { |
|
|
|
float voltage = voltage_steps * VOLTAGE_MULTIPLER; |
|
|
|
display.drawString(24, 0, String(voltage) + "V"); |
|
|
|
|
|
|
|
display.drawString(24, 16, String(profile_gimbal_rate) + " G Rate"); |
|
|
|
display.drawString(24, 32, String(i2c_counter) + " I2C Rate"); |
|
|
|
display.drawString(24, 8, String(profile_gimbal_rate) + " G Rate"); |
|
|
|
display.drawString(24, 16, String(i2c_counter) + " I2C Rate"); |
|
|
|
display.drawString(24, 24, "Throttle: " + String(throttle_steps)); |
|
|
|
display.drawString(24, 32, "Yaw : " + String(yaw_steps)); |
|
|
|
display.drawString(24, 40, "Roll : " + String(roll_steps)); |
|
|
|
display.drawString(24, 48, "Pitch : " + String(pitch_steps)); |
|
|
|
|
|
|
|
// Toggle Buttons Info
|
|
|
|
if(toggle_buttons[TOGGLE_A]) { |
|
|
|