|
|
@ -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)); |
|
|
|
} |
|
|
|
} |
|
|
|