|
|
@ -8,6 +8,24 @@ void BLEGamepad::begin(void) { |
|
|
|
updated = true; |
|
|
|
} |
|
|
|
|
|
|
|
void BLEGamepad::draw_gimbal(TFT_eSprite *m, uint16_t x, uint16_t y) { |
|
|
|
// Top
|
|
|
|
m->drawFastHLine(x, y, 90, TFT_DARKGREEN); |
|
|
|
// Bottom
|
|
|
|
m->drawFastHLine(x, y + 89, 90, TFT_DARKGREEN); |
|
|
|
// Left
|
|
|
|
m->drawFastVLine(x, y, 90, TFT_DARKGREEN); |
|
|
|
// Right
|
|
|
|
m->drawFastVLine(x + 89, y, 90, TFT_DARKGREEN); |
|
|
|
|
|
|
|
// Middle dotted lines
|
|
|
|
for(uint16_t x1 = x; x1 < x + 90; x1 += 10) { |
|
|
|
m->drawFastHLine(x1, y + 45, 5, TFT_DARKGREEN); |
|
|
|
} |
|
|
|
for(uint16_t y1 = y; y1 < y + 90; y1 += 10) { |
|
|
|
m->drawFastVLine(x + 45, y1, 5, TFT_DARKGREEN); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void BLEGamepad::show(TFT_eSprite *m) { |
|
|
|
if(!ble_begin) { |
|
|
@ -19,23 +37,40 @@ void BLEGamepad::show(TFT_eSprite *m) { |
|
|
|
updated = true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if((uint32_t) (millis() - last_voltage_read) > 500) { |
|
|
|
voltage = M5.Axp.GetBatVoltage(); |
|
|
|
current = M5.Axp.GetBatCurrent(); |
|
|
|
|
|
|
|
last_voltage_read = millis(); |
|
|
|
} |
|
|
|
|
|
|
|
if(updated) { |
|
|
|
m->fillRect(0, 0, 320, 240, BLACK); |
|
|
|
m->setTextColor(WHITE, BLACK); |
|
|
|
m->setTextSize(2); |
|
|
|
m->setCursor(0,0); |
|
|
|
m->setCursor(0, 0); |
|
|
|
m->print("Packet(s) Sent: "); |
|
|
|
m->print(String(ble.sent_counter)); |
|
|
|
// m->print(String(inputs.throttle));
|
|
|
|
// m->setCursor(0,16);
|
|
|
|
// m->print(String(inputs.yaw));
|
|
|
|
// m->setCursor(0,32);
|
|
|
|
// m->print(String(inputs.pitch));
|
|
|
|
// m->setCursor(0,48);
|
|
|
|
// m->print(String(inputs.roll));
|
|
|
|
|
|
|
|
m->setCursor(0, 17); |
|
|
|
m->print("Bat: "); |
|
|
|
m->print(String(voltage) + "V " + String(current) + "mA"); |
|
|
|
|
|
|
|
// Draw the gimbal box
|
|
|
|
draw_gimbal(m, 69, 150); |
|
|
|
draw_gimbal(m, 161, 150); |
|
|
|
// Show the position of the left and right gimbal
|
|
|
|
// Convert the throttle and raw to x and y
|
|
|
|
// Temporary assume 4096 = max
|
|
|
|
uint16_t left_gimbal_y = map(inputs.throttle, 0, 4096, 0, 90); |
|
|
|
uint16_t left_gimbal_x = map(inputs.yaw, 0, 4096, 0, 90); |
|
|
|
m->fillCircle(left_gimbal_x + 69, left_gimbal_y + 150, 5, TFT_YELLOW); |
|
|
|
uint16_t right_gimbal_y = map(inputs.pitch, 0, 4096, 0, 90); |
|
|
|
uint16_t right_gimbal_x = map(inputs.roll, 0, 4096, 0, 90); |
|
|
|
m->fillCircle(right_gimbal_x + 161, right_gimbal_y + 150, 5, TFT_YELLOW); |
|
|
|
|
|
|
|
m->setCursor(64,64); |
|
|
|
m->setCursor(90, 130); |
|
|
|
m->print("BLE GAMEPAD"); |
|
|
|
|
|
|
|
m->pushSprite(0,0); |
|
|
|