From e3c768fc4ec7e1312a3c8bfc2953c6afc6679c89 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Wed, 26 Feb 2020 23:48:32 -0500 Subject: [PATCH] Power button mutes/unmutes in-progress calls --- src/main.cpp | 23 ++++++++++++++++++++++- src/sprites.c | 25 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 69eb401..6286ec5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -338,6 +338,9 @@ void callNumber(String number) String contact = mp.checkContact(number); mp.inCall = 1; mp.dataRefreshFlag = 0; + bool muted = false; + const byte *current_call_icon = call_icon; + uint16_t current_call_icon_color = TFT_GREEN; char c; String localBuffer = ""; String buffer = ""; @@ -516,6 +519,24 @@ void callNumber(String number) callState = 1; } } + if (mp.buttons.pressed(14)) // mute, 14 is power button + { + if (mp.sim_module_version == 1 || mp.sim_module_version == 0) + { + muted = !muted; + Serial1.print(F("AT+CMUT=")); + if (muted) { + current_call_icon = call_icon_muted; + current_call_icon_color = TFT_RED; + Serial1.println(1); + } else { + current_call_icon = call_icon; + current_call_icon_color = TFT_GREEN; + Serial1.println(0); + } + mp.waitForOK(); + } + } if (mp.buttons.pressed(BTN_FUN_RIGHT)) // hanging up { @@ -662,7 +683,7 @@ void callNumber(String number) } mp.display.setCursor(9, 9); mp.display.printCenter(temp); - mp.display.drawBitmap(29*scale, 24*scale, call_icon, TFT_GREEN, scale); + mp.display.drawBitmap(29*scale, 24*scale, current_call_icon, current_call_icon_color, scale); mp.display.setCursor(11, 28); if(contact == "") mp.display.printCenter(number); diff --git a/src/sprites.c b/src/sprites.c index 6e94bcf..370402b 100644 --- a/src/sprites.c +++ b/src/sprites.c @@ -489,6 +489,31 @@ const byte call_icon[] PROGMEM = { 24,22, B00000000,B00000111,B11100000, }; +const byte call_icon_muted[] PROGMEM = { 24,22, + B00011100,B00000000,B00000111, + B00111110,B00000000,B00001110, + B01111111,B00000000,B00011100, + B11111111,B10000000,B00111000, + B11111111,B10000000,B01110000, + B11111111,B00000000,B11100000, + B11111110,B00000001,B11000000, + B11111110,B00000011,B10000000, + B11111110,B00000111,B00000000, + B01111111,B00001110,B00000000, + B01111111,B10011100,B00000000, + B00111111,B11111000,B00000000, + B00011111,B11110000,B00000000, + B00001111,B11110000,B01100000, + B00000111,B11111000,B11110000, + B00000011,B11111111,B11111000, + B00000111,B11111111,B11111100, + B00001110,B11111111,B11111100, + B00011100,B01111111,B11111100, + B00111000,B00111111,B11111000, + B01110000,B00011111,B11110000, + B11100000,B00000111,B11100000, +}; + //Lock screen notification icons const byte batteryChargingIcon[] PROGMEM = { 8,7,