re-enable display
This commit is contained in:
parent
5175649281
commit
3cc840e0eb
@ -124,6 +124,7 @@ uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
i2c_config_t conf;
|
i2c_config_t conf;
|
||||||
conf.mode = I2C_MODE_MASTER;
|
conf.mode = I2C_MODE_MASTER;
|
||||||
conf.sda_io_num = u8x8->pins[U8X8_PIN_I2C_DATA];
|
conf.sda_io_num = u8x8->pins[U8X8_PIN_I2C_DATA];
|
||||||
|
@ -14,12 +14,12 @@ using comms::CommsClass;
|
|||||||
DisplayClass::DisplayClass(CommsClass* comms) : comms_(comms) {}
|
DisplayClass::DisplayClass(CommsClass* comms) : comms_(comms) {}
|
||||||
|
|
||||||
void DisplayClass::Init() {
|
void DisplayClass::Init() {
|
||||||
return;
|
|
||||||
ESP_LOGD(TAG, "Initializing u8g2 display");
|
ESP_LOGD(TAG, "Initializing u8g2 display");
|
||||||
// For Heltec ESP32 LoRa
|
// For Heltec ESP32 LoRa
|
||||||
// oled = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, 16, 15, 4);
|
// oled = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, 16, 15, 4);
|
||||||
// For wemos Lolin ESP32
|
// For wemos Lolin ESP32
|
||||||
oled = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, OLED_RESET, OLED_CLOCK, OLED_DATA);
|
oled = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, OLED_RESET,
|
||||||
|
OLED_CLOCK, OLED_DATA);
|
||||||
oled->initDisplay();
|
oled->initDisplay();
|
||||||
oled->clearDisplay();
|
oled->clearDisplay();
|
||||||
oled->setPowerSave(false);
|
oled->setPowerSave(false);
|
||||||
@ -30,28 +30,31 @@ void DisplayClass::Init() {
|
|||||||
ESP_LOGE(TAG, "error starting display thread");
|
ESP_LOGE(TAG, "error starting display thread");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ESP_LOGD(TAG, "Started display thread");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayClass::Run() {
|
void DisplayClass::Run() {
|
||||||
return;
|
#ifdef COMMS_SX127X
|
||||||
int32_t lora_rssi;
|
int32_t lora_rssi;
|
||||||
uint8_t lora_lna_gain;
|
uint8_t lora_lna_gain;
|
||||||
|
int32_t last_packet_rssi;
|
||||||
|
int8_t last_packet_snr;
|
||||||
|
#endif
|
||||||
TickType_t last_packet_tick;
|
TickType_t last_packet_tick;
|
||||||
int32_t last_packet_rssi;
|
|
||||||
int8_t last_packet_snr;
|
|
||||||
|
|
||||||
|
ESP_LOGD(TAG, "Started display thread");
|
||||||
while (true) {
|
while (true) {
|
||||||
// ESP_LOGI(TAG, "inputs %s", inputs.ToString());
|
|
||||||
|
|
||||||
oled->firstPage();
|
oled->firstPage();
|
||||||
|
#ifdef COMMS_SX127X
|
||||||
lora_rssi = comms_->ReadRssi();
|
lora_rssi = comms_->ReadRssi();
|
||||||
lora_lna_gain = comms_->ReadLnaGain();
|
lora_lna_gain = comms_->ReadLnaGain();
|
||||||
|
#endif
|
||||||
|
|
||||||
comms_->Lock();
|
comms_->Lock();
|
||||||
last_packet_tick = comms_->last_packet_tick;
|
last_packet_tick = comms_->last_packet_tick;
|
||||||
|
#ifdef COMMS_SX127X
|
||||||
last_packet_rssi = comms_->last_packet_rssi;
|
last_packet_rssi = comms_->last_packet_rssi;
|
||||||
last_packet_snr = comms_->last_packet_snr;
|
last_packet_snr = comms_->last_packet_snr;
|
||||||
|
#endif
|
||||||
comms_->Unlock();
|
comms_->Unlock();
|
||||||
do {
|
do {
|
||||||
oled->drawRFrame(0, 0, OLED_W, OLED_H, 4);
|
oled->drawRFrame(0, 0, OLED_W, OLED_H, 4);
|
||||||
@ -65,25 +68,27 @@ void DisplayClass::Run() {
|
|||||||
oled->printf("heap allc/free %d/%d", heap_info.total_allocated_bytes,
|
oled->printf("heap allc/free %d/%d", heap_info.total_allocated_bytes,
|
||||||
heap_info.total_free_bytes);
|
heap_info.total_free_bytes);
|
||||||
|
|
||||||
|
#ifdef COMMS_SX127X
|
||||||
oled->setCursor(4, 3 * 8);
|
oled->setCursor(4, 3 * 8);
|
||||||
oled->printf("rssi: %d lna gain: %d", lora_rssi, lora_lna_gain);
|
oled->printf("rssi: %d lna gain: %d", lora_rssi, lora_lna_gain);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (last_packet_tick > 0) {
|
if (last_packet_tick > 0) {
|
||||||
double time_since_last_packet =
|
double time_since_last_packet =
|
||||||
1000.0f /
|
static_cast<float>((xTaskGetTickCount() - last_packet_tick) *
|
||||||
((xTaskGetTickCount() - last_packet_tick) * portTICK_RATE_MS);
|
portTICK_RATE_MS) /
|
||||||
|
1000.f;
|
||||||
oled->setCursor(4, 4 * 8);
|
oled->setCursor(4, 4 * 8);
|
||||||
oled->printf("last pkt rx %f s ago", time_since_last_packet);
|
oled->printf("last pkt rx %.2f s ago", time_since_last_packet);
|
||||||
|
#ifdef COMMS_SX127X
|
||||||
oled->setCursor(4, 5 * 8);
|
oled->setCursor(4, 5 * 8);
|
||||||
oled->printf("pkt rssi: %d, snr: %f", last_packet_rssi,
|
oled->printf("pkt rssi: %d, snr: %f", last_packet_rssi,
|
||||||
last_packet_snr * 0.25f);
|
last_packet_snr * 0.25f);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
oled->setCursor(4, 4 * 8);
|
oled->setCursor(4, 4 * 8);
|
||||||
oled->print("no pkt rx");
|
oled->print("no pkt rx");
|
||||||
}
|
}
|
||||||
// oled->setCursor(4, 6 * 8);
|
|
||||||
// oled->printf("motors: (%f, %f)", outputs.left_motor,
|
|
||||||
// outputs.right_motor);
|
|
||||||
} while (oled->nextPage());
|
} while (oled->nextPage());
|
||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ MPU::~MPU() { delete mpu_; }
|
|||||||
|
|
||||||
void MPU::Init() {
|
void MPU::Init() {
|
||||||
xSemaphoreTake(i2c_mutex, portMAX_DELAY);
|
xSemaphoreTake(i2c_mutex, portMAX_DELAY);
|
||||||
mpu_bus_ = &i2c1;
|
mpu_bus_ = &i2c0;
|
||||||
// This is shared with the oled, so just use those pins
|
// This is shared with the oled, so just use those pins
|
||||||
mpu_bus_->setTimeout(10);
|
mpu_bus_->setTimeout(10);
|
||||||
mpu_bus_->begin(MPU_SDA, MPU_SCL, 400000);
|
mpu_bus_->begin(MPU_SDA, MPU_SCL, 400000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user