diff --git a/src/core/display.cpp b/src/core/display.cpp index 5c2c5412..0f4e6ff8 100644 --- a/src/core/display.cpp +++ b/src/core/display.cpp @@ -372,7 +372,7 @@ void drawWifiSmall(int x, int y) { void drawWifi(int x, int y) { tft.fillRect(x,y,80,80,BGCOLOR); - tft.fillCircle(40+x,60+y,6,FGCOLOR); + tft.fillSmoothCircle(40+x,60+y,6,FGCOLOR); tft.drawSmoothArc(40+x,60+y,26,20,130,230,FGCOLOR, BGCOLOR,true); tft.drawSmoothArc(40+x,60+y,46,40,130,230,FGCOLOR, BGCOLOR,true); } @@ -395,6 +395,9 @@ void drawBLE(int x, int y) { tft.fillRect(x,y,80,80,BGCOLOR); tft.drawWideLine(40+x,53+y,2+x,26+y,5,FGCOLOR,BGCOLOR); tft.drawWideLine(40+x,26+y,2+x,53+y,5,FGCOLOR,BGCOLOR); + tft.drawWideLine(40+x,53+y,20+x,68+y,5,FGCOLOR,BGCOLOR); + tft.drawWideLine(40+x,26+y,20+x,12+y,5,FGCOLOR,BGCOLOR); + tft.drawWideLine(20+x,12+y,20+x,68+y,5,FGCOLOR,BGCOLOR); tft.fillTriangle(40+x,26+y,20+x,40+y,20+x,12+y,FGCOLOR); tft.fillTriangle(40+x,53+y,20+x,40+y,20+x,68+y,FGCOLOR); tft.drawArc(40+x,40+y,10,12,210,330,FGCOLOR,BGCOLOR); @@ -413,7 +416,7 @@ void drawCfg(int x, int y) { void drawRf(int x, int y) { tft.fillRect(x,y,80,80,BGCOLOR); - tft.fillCircle(40+x,30+y,7,FGCOLOR); + tft.fillSmoothCircle(40+x,30+y,7,FGCOLOR); tft.fillTriangle(40+x,40+y,25+x,70+y,55+x,70+y,FGCOLOR); tft.drawArc(40+x,30+y,18,15,40,140,FGCOLOR,BGCOLOR); tft.drawArc(40+x,30+y,28,25,40,140,FGCOLOR,BGCOLOR); @@ -445,7 +448,7 @@ void drawIR(int x, int y) { void drawOther(int x, int y) { tft.fillRect(x,y,80,80,BGCOLOR); - tft.fillCircle(40+x,40+y,7,FGCOLOR); + tft.fillSmoothCircle(40+x,40+y,7,FGCOLOR); tft.drawArc(40+x,40+y,18,15,0,340,FGCOLOR,BGCOLOR); tft.drawArc(40+x,40+y,25,22,20,360,FGCOLOR,BGCOLOR); tft.drawArc(40+x,40+y,32,29,0,200,FGCOLOR,BGCOLOR); diff --git a/src/core/main_menu.cpp b/src/core/main_menu.cpp index 81fd5570..31e221f8 100644 --- a/src/core/main_menu.cpp +++ b/src/core/main_menu.cpp @@ -8,8 +8,8 @@ #include "modules/ble/ble_spam.h" #include "modules/others/openhaystack.h" #include "modules/others/tururururu.h" -#include "modules/others/TV-B-Gone.h" #include "modules/others/webInterface.h" +#include "modules/ir/TV-B-Gone.h" #include "modules/rf/rf.h" #include "modules/rfid/rfid.h" #include "modules/rfid/tag_o_matic.h" diff --git a/src/core/mykeyboard.cpp b/src/core/mykeyboard.cpp index 68209e6f..f49411b0 100644 --- a/src/core/mykeyboard.cpp +++ b/src/core/mykeyboard.cpp @@ -1,6 +1,6 @@ #include "mykeyboard.h" #include "powerSave.h" -#include "modules/others/TV-B-Gone.h" +#include "modules/ir/TV-B-Gone.h" #include "modules/rf/rf.h" #include "modules/others/bad_usb.h" #include "modules/others/webInterface.h" @@ -12,10 +12,10 @@ bool checkNextPress(){ #if defined (CARDPUTER) Keyboard.update(); if(Keyboard.isKeyPressed('/') || Keyboard.isKeyPressed('.')) - #else - if(digitalRead(DW_BTN)==LOW) + #else + if(digitalRead(DW_BTN)==LOW) #endif - { + { if(wakeUpScreen()){ delay(200); return false; @@ -29,14 +29,14 @@ bool checkNextPress(){ /* Verifies Down Btn to go to next item */ bool checkPrevPress() { #if defined(STICK_C_PLUS2) - if(digitalRead(UP_BTN)==LOW) + if(digitalRead(UP_BTN)==LOW) #elif defined(STICK_C_PLUS) if(axp192.GetBtnPress()) #elif defined(CARDPUTER) Keyboard.update(); if(Keyboard.isKeyPressed(',') || Keyboard.isKeyPressed(';')) #endif - { + { if(wakeUpScreen()){ delay(200); return false; @@ -54,9 +54,9 @@ bool checkSelPress(){ Keyboard.update(); if(Keyboard.isKeyPressed(KEY_ENTER) || digitalRead(0)==LOW) #else - if(digitalRead(SEL_BTN)==LOW) + if(digitalRead(SEL_BTN)==LOW) #endif - { + { if(wakeUpScreen()){ delay(200); return false; @@ -69,7 +69,7 @@ bool checkSelPress(){ bool checkEscPress(){ #if defined(STICK_C_PLUS2) - if(digitalRead(UP_BTN)==LOW) + if(digitalRead(UP_BTN)==LOW) #elif defined(STICK_C_PLUS) if(axp192.GetBtnPress()) #elif defined (CARDPUTER) @@ -97,7 +97,7 @@ bool checkAnyKeyPress() { return true; // else return false; - + } void checkShortcutPress(){ @@ -124,7 +124,7 @@ String keyboard(String mytext, int maxSize, String msg) { int x2=0; int y2=0; char keys[4][12][2] = { //4 lines, with 12 characteres, low and high caps - { + { { '1', '!' },//1 { '2', '@' },//2 { '3', '#' },//3 @@ -136,9 +136,9 @@ String keyboard(String mytext, int maxSize, String msg) { { '9', '(' },//9 { '0', ')' },//10 { '-', '_' },//11 - { '=', '+' } //12 - }, - { + { '=', '+' } //12 + }, + { { 'q', 'Q' },//1 { 'w', 'W' },//2 { 'e', 'E' },//3 @@ -152,7 +152,7 @@ String keyboard(String mytext, int maxSize, String msg) { { '[', '{' },//11 { ']', '}' } //12 }, - { + { { 'a', 'A' },//1 { 's', 'S' },//2 { 'd', 'D' },//3 @@ -166,7 +166,7 @@ String keyboard(String mytext, int maxSize, String msg) { { '"', '\'' },//11 { '|', '\\' } //12 }, - { + { { '\\', '|' },//1 { 'z', 'Z' },//2 { 'x', 'X' },//3 @@ -178,7 +178,7 @@ String keyboard(String mytext, int maxSize, String msg) { { ',', '<' },//9 { '.', '>' },//10 { '?', '/' },//11 - { '/', '/' } //12 + { '/', '/' } //12 } }; @@ -209,12 +209,12 @@ String keyboard(String mytext, int maxSize, String msg) { else tft.setTextColor(TFT_WHITE, BGCOLOR); tft.drawString("OK", 18, 4); - + if(x==1 && y==-1) { tft.setTextColor(BGCOLOR, TFT_WHITE); tft.fillRect(55,2,50,20,TFT_WHITE); } else if(caps) { tft.fillRect(55,2,50,20,TFT_DARKGREY); tft.setTextColor(TFT_WHITE, TFT_DARKGREY); } else tft.setTextColor(TFT_WHITE, BGCOLOR); tft.drawString("CAP", 64, 4); - + if(x==2 && y==-1) { tft.setTextColor(BGCOLOR, TFT_WHITE); tft.fillRect(107,2,50,20,TFT_WHITE); } else tft.setTextColor(TFT_WHITE, BGCOLOR); @@ -228,19 +228,19 @@ String keyboard(String mytext, int maxSize, String msg) { tft.setTextSize(FP); tft.setTextColor(TFT_WHITE, 0x5AAB); tft.drawString(msg.substring(0,38), 3, 24); - + tft.setTextSize(FM); // reseta o quadrado do texto if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,WIDTH-3,20,BGCOLOR); // mystring Rectangle // escreve o texto - tft.setTextColor(TFT_WHITE); - if(mytext.length()>19) { + tft.setTextColor(TFT_WHITE); + if(mytext.length()>19) { tft.setTextSize(FP); - if(mytext.length()>38) { + if(mytext.length()>38) { tft.drawString(mytext.substring(0,38), 5, 34); tft.drawString(mytext.substring(38,mytext.length()), 5, 42); - } + } else { tft.drawString(mytext, 5, 34); } @@ -249,9 +249,9 @@ String keyboard(String mytext, int maxSize, String msg) { } //desenha o retangulo colorido tft.drawRect(3,32,WIDTH-3,20,FGCOLOR); // mystring Rectangle - - tft.setTextColor(TFT_WHITE, BGCOLOR); + + tft.setTextColor(TFT_WHITE, BGCOLOR); tft.setTextSize(FM); @@ -261,8 +261,8 @@ String keyboard(String mytext, int maxSize, String msg) { if(x2==j && y2==i) { tft.setTextColor(TFT_WHITE, BGCOLOR); tft.fillRect(j*18+11,i*19+54,21,19,BGCOLOR);} /* If selected, change font color and draw Rectangle*/ if(x==j && y==i) { tft.setTextColor(BGCOLOR, TFT_WHITE); tft.fillRect(j*18+11,i*19+54,21,19,TFT_WHITE);} - - + + /* Print the letters */ if(!caps) tft.drawChar(keys[i][j][0], (j*18+16), (i*19+56)); else tft.drawChar(keys[i][j][1], (j*18+16), (i*19+56)); @@ -278,12 +278,12 @@ String keyboard(String mytext, int maxSize, String msg) { } //cursor handler - if(mytext.length()>19) { + if(mytext.length()>19) { tft.setTextSize(FP); - if(mytext.length()>38) { + if(mytext.length()>38) { cY=42; cX=5+(mytext.length()-38)*LW; - } + } else { cY=34; cX=5+mytext.length()*LW; @@ -319,13 +319,13 @@ String keyboard(String mytext, int maxSize, String msg) { else tft.setTextSize(FM); tft.setCursor((cX-fS*LW),cY); tft.setTextColor(FGCOLOR,BGCOLOR); - tft.print(" "); + tft.print(" "); tft.setTextColor(TFT_WHITE, 0x5AAB); tft.setCursor(cX-fS*LW,cY); cX=tft.getCursorX(); cY=tft.getCursorY(); if(mytext.length()==19) redraw = true; - if(mytext.length()==38) redraw = true; + if(mytext.length()==38) redraw = true; } if (status.enter) { break; @@ -335,7 +335,7 @@ String keyboard(String mytext, int maxSize, String msg) { if(checkSelPress()) break; #else - if(checkSelPress()) { + if(checkSelPress()) { tft.setCursor(cX,cY); int z=0; if(caps) z=1; @@ -349,11 +349,11 @@ String keyboard(String mytext, int maxSize, String msg) { else tft.setTextSize(FM); tft.setCursor((cX-fS*LW),cY); tft.setTextColor(FGCOLOR,BGCOLOR); - tft.print(" "); + tft.print(" "); tft.setTextColor(TFT_WHITE, 0x5AAB); tft.setCursor(cX-fS*LW,cY); cX=tft.getCursorX(); - cY=tft.getCursorY(); + cY=tft.getCursorY(); } else if(x>2 && y==-1 && mytext.length()-1 && mytext.length()3) { y=-1; } else if(y<-1) y=3; redraw = true; @@ -393,7 +393,7 @@ String keyboard(String mytext, int maxSize, String msg) { #endif } - + //Resets screen when finished writing tft.fillRect(0,0,tft.width(),tft.height(),BGCOLOR); resetTftDisplay(); @@ -411,7 +411,7 @@ String keyboard(String mytext, int maxSize, String msg) { int x=0; int y=-1; char keys[4][12][2] = { //4 lines, with 12 characteres, low and high caps - { + { { '1', '!' },//1 { '2', '@' },//2 { '3', '#' },//3 @@ -423,9 +423,9 @@ String keyboard(String mytext, int maxSize, String msg) { { '9', '(' },//9 { '0', ')' },//10 { '-', '_' },//11 - { '=', '+' } //12 - }, - { + { '=', '+' } //12 + }, + { { 'q', 'Q' },//1 { 'w', 'W' },//2 { 'e', 'E' },//3 @@ -439,7 +439,7 @@ String keyboard(String mytext, int maxSize, String msg) { { '[', '{' },//11 { ']', '}' } //12 }, - { + { { 'a', 'A' },//1 { 's', 'S' },//2 { 'd', 'D' },//3 @@ -453,7 +453,7 @@ String keyboard(String mytext, int maxSize, String msg) { { '"', '\'' },//11 { '|', '\\' } //12 }, - { + { { '\\', '|' },//1 { 'z', 'Z' },//2 { 'x', 'X' },//3 @@ -465,7 +465,7 @@ String keyboard(String mytext, int maxSize, String msg) { { ',', '<' },//9 { '.', '>' },//10 { '?', '/' },//11 - { '/', '/' } //12 + { '/', '/' } //12 } }; @@ -492,12 +492,12 @@ String keyboard(String mytext, int maxSize, String msg) { else tft.setTextColor(TFT_WHITE, BGCOLOR); tft.drawString("OK", 10, 4); - + if(x==1 && y==-1) { tft.setTextColor(BGCOLOR, TFT_WHITE); tft.fillRect(27,2,25,10,TFT_WHITE); } else if(caps) { tft.fillRect(55,2,50,20,TFT_DARKGREY); tft.setTextColor(TFT_WHITE, TFT_DARKGREY); } else tft.setTextColor(TFT_WHITE, BGCOLOR); tft.drawString("CAP", 30, 4); - + if(x==2 && y==-1) { tft.setTextColor(BGCOLOR, TFT_WHITE); tft.fillRect(52,2,25,10,TFT_WHITE); } else tft.setTextColor(TFT_WHITE, BGCOLOR); @@ -510,26 +510,26 @@ String keyboard(String mytext, int maxSize, String msg) { tft.setTextSize(FP); tft.setTextColor(TFT_WHITE); tft.drawString(msg.substring(0,38), 3, 14); - + tft.setTextSize(FM); - tft.setTextColor(TFT_WHITE, 0x5AAB); - if(mytext.length()>19) { + tft.setTextColor(TFT_WHITE, 0x5AAB); + if(mytext.length()>19) { tft.setTextSize(FP); - if(mytext.length()>38) { + if(mytext.length()>38) { tft.drawString(mytext.substring(0,38), 5, 24); tft.drawString(mytext.substring(38,mytext.length()), 5, 32); - } + } else { tft.drawString(mytext, 5, 24); } } else { tft.drawString(mytext, 5, 24); } - - tft.setTextColor(TFT_WHITE, BGCOLOR); + + tft.setTextColor(TFT_WHITE, BGCOLOR); tft.setTextSize(FM); @@ -537,7 +537,7 @@ String keyboard(String mytext, int maxSize, String msg) { for(j=0;j<12;j++) { /* If selected, change font color and draw Rectangle*/ if(x==j && y==i) { tft.setTextColor(BGCOLOR, TFT_WHITE); tft.fillRect(j*11+15,i*9+34,10,10,TFT_WHITE);} - + /* Print the letters */ if(!caps) tft.drawChar(keys[i][j][0], (j*11+18), (i*9+36)); else tft.drawChar(keys[i][j][1], (j*11+18), (i*9+36)); @@ -552,7 +552,7 @@ String keyboard(String mytext, int maxSize, String msg) { /* When Select a key in keyboard */ - if(checkSelPress()) { + if(checkSelPress()) { int z=0; if(caps) z=1; else z=0; @@ -565,10 +565,10 @@ String keyboard(String mytext, int maxSize, String msg) { delay(200); } - /* Down Btn to move in X axis (to the right) */ - if(checkNextPress()) - { - delay(200); + /* Down Btn to move in X axis (to the right) */ + if(checkNextPress()) + { + delay(200); if(checkNextPress()) { x--; delay(250); } // Long Press else x++; // Short Press @@ -578,20 +578,20 @@ String keyboard(String mytext, int maxSize, String msg) { redraw = true; } /* UP Btn to move in Y axis (Downwards) */ - if(checkPrevPress()) { + if(checkPrevPress()) { delay(200); if(checkPrevPress()) { y--; delay(250); }// Long press else y++; // short press - + if(y>3) { y=-1; } - else if(y<-1) y=3; + else if(y<-1) y=3; redraw = true; } } - + //Resets screen when finished writing tft.fillRect(0,0,tft.width(),tft.height(),BGCOLOR); resetTftDisplay(); diff --git a/src/core/sd_functions.cpp b/src/core/sd_functions.cpp index d4aa796c..fad5d41a 100644 --- a/src/core/sd_functions.cpp +++ b/src/core/sd_functions.cpp @@ -436,9 +436,9 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) { if(fileList[index][2]=="folder") { options = { {"New Folder", [=]() { createFolder(fs, Folder); }}, - {"Rename", [=]() { renameFile(fs, fileList[index][1], fileList[index][0]); }}, - {"Delete", [=]() { deleteFromSd(fs, fileList[index][1]); }}, - {"Main Menu", [=]() { backToMenu(); }}, + {"Rename", [=]() { renameFile(fs, fileList[index][1], fileList[index][0]); }}, + {"Delete", [=]() { deleteFromSd(fs, fileList[index][1]); }}, + {"Main Menu", [=]() { backToMenu(); }}, }; delay(200); loopOptions(options); @@ -467,8 +467,8 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) { } else if (fileList[index][2]=="file") { options = { {"New Folder", [=]() { createFolder(fs, Folder); }}, - {"Rename", [=]() { renameFile(fs, fileList[index][1], fileList[index][0]); }}, - {"Copy", [=]() { copyFile(fs, fileList[index][1]); }}, + {"Rename", [=]() { renameFile(fs, fileList[index][1], fileList[index][0]); }}, + {"Copy", [=]() { copyFile(fs, fileList[index][1]); }}, }; if(fileToCopy!="") options.push_back({"Paste", [=]() { pasteFile(fs, Folder); }}); options.push_back({"Delete", [=]() { deleteFromSd(fs, fileList[index][1]); }}); diff --git a/src/core/serialcmds.cpp b/src/core/serialcmds.cpp index 441c78bb..4f9ad811 100644 --- a/src/core/serialcmds.cpp +++ b/src/core/serialcmds.cpp @@ -3,7 +3,7 @@ #include "globals.h" #include #include -#include "modules/others/TV-B-Gone.h" +#include "modules/ir/TV-B-Gone.h" #include "cJSON.h" #include // for PRIu64 @@ -29,7 +29,7 @@ void SerialPrintHexString(uint64_t val) { void handleSerialCommands() { String cmd_str; - + /* if (Serial.available() >= MIN_CMD_LEN ) { size_t len = Serial.available(); @@ -44,24 +44,24 @@ void handleSerialCommands() { //log_d("nothing received"); return; }*/ - - if (Serial.available() >= 1) { + + if (Serial.available() >= 1) { cmd_str = Serial.readStringUntil('\n'); } else { // try again on next iteration return; - } + } //log_d(cmd_str.c_str()); cmd_str.trim(); cmd_str.toLowerCase(); // case-insensitive matching - + // TODO: more commands https://docs.flipper.net/development/cli#0Z9fs if(cmd_str == "" ) { // empty return; } - + if(cmd_str.startsWith("ir") ) { // ir tx
@@ -89,7 +89,7 @@ void handleSerialCommands() { } // TODO: more protocols: Samsung32, SIRC //if(cmd_str.startsWith("ir tx raw")){ - + if(cmd_str.startsWith("irsend")) { // tasmota json command https://tasmota.github.io/docs/Tasmota-IR/#sending-ir-commands // e.g. IRSend {"Protocol":"NEC","Bits":32,"Data":"0x20DF10EF"} @@ -102,7 +102,7 @@ void handleSerialCommands() { IRsend irsend(IrTx,true); // Set the GPIO to be used to sending the message. //IRsend irsend(IrTx); //inverted = false irsend.begin(); - cJSON *root = cJSON_Parse(cmd_str.c_str() + 6); + cJSON *root = cJSON_Parse(cmd_str.c_str() + 6); if (root == NULL) { Serial.println("This is NOT json format"); return; @@ -111,7 +111,7 @@ void handleSerialCommands() { const char *dataStr = ""; String protocolStr = "nec"; // defaults to NEC protocol - cJSON * protocolItem = cJSON_GetObjectItem(root,"protocol"); + cJSON * protocolItem = cJSON_GetObjectItem(root,"protocol"); cJSON * dataItem = cJSON_GetObjectItem(root, "data"); cJSON * bitsItem = cJSON_GetObjectItem(root,"bits"); @@ -121,7 +121,7 @@ void handleSerialCommands() { dataStr = dataItem->valuestring; } else { Serial.println("missing or invalid data to send"); - return; + return; } //String dataStr = cmd_str.substring(36, 36+8); uint64_t data = strtoul(dataStr, nullptr, 16); @@ -129,27 +129,27 @@ void handleSerialCommands() { //SerialPrintHexString(data); //Serial.println(bits); //Serial.println(protocolItem->valuestring); - + cJSON_Delete(root); - + if(protocolStr == "nec"){ - // sendNEC(uint64_t data, uint16_t nbits, uint16_t repeat) + // sendNEC(uint64_t data, uint16_t nbits, uint16_t repeat) irsend.sendNEC(data, bits, 10); } // TODO: more protocols } - + // turn off the led digitalWrite(IrTx, LED_OFF); //backToMenu(); return; } // end of ir commands - + if(cmd_str.startsWith("rf") || cmd_str.startsWith("subghz" )) { if(RfTx==0) RfTx=GROVE_SDA; // quick fix pinMode(RfTx, OUTPUT); //Serial.println(RfTx); - + /* WIP: if(cmd_str.startsWith("subghz tx")) { // flipperzero-like cmd https://docs.flipper.net/development/cli/#wLVht @@ -160,8 +160,8 @@ void handleSerialCommands() { // tasmota json command https://tasmota.github.io/docs/Tasmota-IR/#sending-ir-commands // e.g. RfSend {"Data":"0x447503","Bits":24,"Protocol":1,"Pulse":174,"Repeat":10} // on // e.g. RfSend {"Data":"0x44750C","Bits":24,"Protocol":1,"Pulse":174,"Repeat":10} // off - - cJSON *root = cJSON_Parse(cmd_str.c_str() + 6); + + cJSON *root = cJSON_Parse(cmd_str.c_str() + 6); if (root == NULL) { Serial.println("This is NOT json format"); return; @@ -171,8 +171,8 @@ void handleSerialCommands() { int protocol = 1; // defaults to 1 int pulse = 0; // 0 leave the library use the default value depending on protocol int repeat = 10; - - cJSON * protocolItem = cJSON_GetObjectItem(root,"protocol"); + + cJSON * protocolItem = cJSON_GetObjectItem(root,"protocol"); cJSON * dataItem = cJSON_GetObjectItem(root, "data"); cJSON * bitsItem = cJSON_GetObjectItem(root,"bits"); cJSON * pulseItem = cJSON_GetObjectItem(root,"pulse"); @@ -187,21 +187,21 @@ void handleSerialCommands() { } else { Serial.println("missing or invalid data to send"); cJSON_Delete(root); - return; + return; } //String dataStr = cmd_str.substring(36, 36+8); uint64_t data = strtoul(dataStr, nullptr, 16); //Serial.println(dataStr); //SerialPrintHexString(data); //Serial.println(bits); - + RCSwitch_send(data, bits, pulse, protocol, repeat); - + cJSON_Delete(root); return; } } // endof rf - + #ifndef STICK_C_PLUS if(cmd_str.startsWith("music_player " ) || cmd_str.startsWith("tts" ) || cmd_str.startsWith("say" ) ) { // TODO: move in audio.cpp module @@ -212,7 +212,7 @@ void handleSerialCommands() { #endif AudioGenerator* generator = NULL; AudioFileSource* source = NULL; - + if(cmd_str.startsWith("music_player " ) ) { // || cmd_str.startsWith("play " ) String song = cmd_str.substring(13, cmd_str.length()); if(song.indexOf(":") != -1) { @@ -264,7 +264,7 @@ void handleSerialCommands() { } } } - + //TODO: tone // https://github.com/earlephilhower/ESP8266Audio/issues/643 @@ -279,7 +279,7 @@ void handleSerialCommands() { delete sam; return; } - + if(generator && source && audioout) { generator->begin(source, audioout); // TODO async play @@ -352,20 +352,20 @@ void handleSerialCommands() { //esp_timer_stop(screensaver_timer); return; } - + if(cmd_str == "clock" ) { //esp_timer_stop(screensaver_timer); // disable screensaver while the clock is running runClockLoop(); return; } - + // TODO: "storage" cmd to manage files https://docs.flipper.net/development/cli/#Xgais - + // TODO: "gpio" cmds https://docs.flipper.net/development/cli/#aqA4b - - + + Serial.println("unsupported serial command: " + cmd_str); } - + diff --git a/src/modules/others/TV-B-Gone.cpp b/src/modules/ir/TV-B-Gone.cpp similarity index 100% rename from src/modules/others/TV-B-Gone.cpp rename to src/modules/ir/TV-B-Gone.cpp diff --git a/src/modules/others/TV-B-Gone.h b/src/modules/ir/TV-B-Gone.h similarity index 100% rename from src/modules/others/TV-B-Gone.h rename to src/modules/ir/TV-B-Gone.h diff --git a/src/modules/others/WORLD_IR_CODES.h b/src/modules/ir/WORLD_IR_CODES.h similarity index 100% rename from src/modules/others/WORLD_IR_CODES.h rename to src/modules/ir/WORLD_IR_CODES.h diff --git a/src/modules/rf/rf.cpp b/src/modules/rf/rf.cpp index ac4b4d90..d2500357 100644 --- a/src/modules/rf/rf.cpp +++ b/src/modules/rf/rf.cpp @@ -230,7 +230,7 @@ uint32_t hexStringToDecimal(const char* hexString) { void decimalToHexString(uint64_t decimal, char* output) { char hexDigits[] = "0123456789ABCDEF"; - char temp[65]; + char temp[65]; int index = 15; // Initialize tem string with zeros @@ -257,7 +257,7 @@ void decimalToHexString(uint64_t decimal, char* output) { } static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength) { - static char bin[64]; + static char bin[64]; unsigned int i=0; while (Dec > 0) { @@ -273,7 +273,7 @@ static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength) { } } bin[bitLength] = '\0'; - + return bin; } @@ -295,7 +295,7 @@ void RCSwitch_Read_Raw() { Serial.println("Available"); if(value) { Serial.println("has value"); - unsigned int* raw = rcswitch.getReceivedRawdata(); + unsigned int* raw = rcswitch.getReceivedRawdata(); received.key=rcswitch.getReceivedValue(); received.protocol=rcswitch.getReceivedProtocol(); received.te=rcswitch.getReceivedDelay(); @@ -313,21 +313,23 @@ void RCSwitch_Read_Raw() { decimalToHexString(received.key,hexString); tft.println("Key: " + String(hexString)); tft.setCursor(10, tft.getCursorY()); - tft.println("Binary: " + String(b)); + tft.println("Binary: " + String(b)); tft.setCursor(10, tft.getCursorY()); - tft.println("Lenght: " + String(received.Bit) + " bits"); + tft.println("Lenght: " + String(received.Bit) + " bits"); tft.setCursor(10, tft.getCursorY()); tft.println("PulseLenght: " + String(received.te) + "ms"); tft.setCursor(10, tft.getCursorY()); tft.println("Protocol: " + String(received.protocol)); - tft.println("\n\nPress " + String(BTN_ALIAS) + "for options."); + tft.println("\n"); + tft.setCursor(10, tft.getCursorY()); + tft.println("Press " + String(BTN_ALIAS) + "for options."); } rcswitch.resetAvailable(); } if(received.key>0) { if(checkSelPress()) { int chosen=0; - options = { + options = { {"Replay signal", [&]() { chosen=1; } }, {"Save signal", [&]() { chosen=2; } }, }; @@ -338,7 +340,7 @@ void RCSwitch_Read_Raw() { sendRfCommand(received); addToRecentCodes(received); goto RestartRec; - } + } else if (chosen==2) { int i=0; File file; @@ -361,7 +363,7 @@ void RCSwitch_Read_Raw() { file.println("RAW_Data: " + received.data); file.println("TE: " + String(received.te)); displaySuccess(FS + "/bruce_" + String(i) + ".sub"); - } else { + } else { Serial.println("Fail saving data to LittleFS"); displayError("Error saving file"); } @@ -392,10 +394,10 @@ void RCSwitch_RAW_send(int nTransmitterPin, int * ptrtransmittimings, struct Pro bool currentlogiclevel = true; int nRepeatTransmit = 1; //HighLow pulses ; - + for (int nRepeat = 0; nRepeat < nRepeatTransmit; nRepeat++) { unsigned int currenttiming = 0; - while( ptrtransmittimings[currenttiming] ) { // && currenttiming < RCSWITCH_MAX_CHANGES + while( ptrtransmittimings[currenttiming] ) { // && currenttiming < RCSWITCH_MAX_CHANGES if(ptrtransmittimings[currenttiming] >= 0) { currentlogiclevel = true; //pulses = protocol.one; @@ -405,24 +407,24 @@ void RCSwitch_RAW_send(int nTransmitterPin, int * ptrtransmittimings, struct Pro ptrtransmittimings[currenttiming] = (-1) * ptrtransmittimings[currenttiming]; // invert sign //pulses = protocol.zero; } - + digitalWrite(nTransmitterPin, currentlogiclevel ? HIGH : LOW); delayMicroseconds( ptrtransmittimings[currenttiming] ); - + /* uint8_t firstLogicLevel = (protocol.invertedSignal) ? LOW : HIGH; uint8_t secondLogicLevel = (protocol.invertedSignal) ? HIGH : LOW; - + digitalWrite(nTransmitterPin, firstLogicLevel); delayMicroseconds( protocol.pulseLength * pulses.high); digitalWrite(nTransmitterPin, secondLogicLevel); delayMicroseconds( protocol.pulseLength * pulses.low); * */ - + Serial.print(ptrtransmittimings[currenttiming]); Serial.print("="); Serial.println(currentlogiclevel); - + currenttiming++; } digitalWrite(nTransmitterPin, LOW); @@ -430,7 +432,7 @@ void RCSwitch_RAW_send(int nTransmitterPin, int * ptrtransmittimings, struct Pro } -void sendRfCommand(struct RfCodes rfcode) { +void sendRfCommand(struct RfCodes rfcode) { uint32_t frequency = rfcode.frequency; String protocol = rfcode.protocol; String preset = rfcode.preset; @@ -442,7 +444,7 @@ void sendRfCommand(struct RfCodes rfcode) { Serial.println(frequency); Serial.println(preset); Serial.println(protocol); - */ + */ if(frequency != 433920000) { Serial.print("unsupported frequency: "); Serial.println(frequency); @@ -450,7 +452,7 @@ void sendRfCommand(struct RfCodes rfcode) { } // MEMO: frequency is fixed with some transmitters https://github.com/sui77/rc-switch/issues/256 // TODO: add frequency switching via CC1101 https://github.com/LSatan/SmartRC-CC1101-Driver-Lib - + // Radio preset name (configures modulation, bandwidth, filters, etc.). struct Protocol rcswitch_protocol; int rcswitch_protocol_no = 1; @@ -471,26 +473,26 @@ void sendRfCommand(struct RfCodes rfcode) { return; } /* supported flipper presets: - FuriHalSubGhzPresetIDLE, // < default configuration - FuriHalSubGhzPresetOok270Async, ///< OOK, bandwidth 270kHz, asynchronous - FuriHalSubGhzPresetOok650Async, ///< OOK, bandwidth 650kHz, asynchronous - FuriHalSubGhzPreset2FSKDev238Async, //< FM, deviation 2.380371 kHz, asynchronous - FuriHalSubGhzPreset2FSKDev476Async, //< FM, deviation 47.60742 kHz, asynchronous - FuriHalSubGhzPresetMSK99_97KbAsync, //< MSK, deviation 47.60742 kHz, 99.97Kb/s, asynchronous - FuriHalSubGhzPresetGFSK9_99KbAsync, //< GFSK, deviation 19.042969 kHz, 9.996Kb/s, asynchronous + FuriHalSubGhzPresetIDLE, // < default configuration + FuriHalSubGhzPresetOok270Async, ///< OOK, bandwidth 270kHz, asynchronous + FuriHalSubGhzPresetOok650Async, ///< OOK, bandwidth 650kHz, asynchronous + FuriHalSubGhzPreset2FSKDev238Async, //< FM, deviation 2.380371 kHz, asynchronous + FuriHalSubGhzPreset2FSKDev476Async, //< FM, deviation 47.60742 kHz, asynchronous + FuriHalSubGhzPresetMSK99_97KbAsync, //< MSK, deviation 47.60742 kHz, 99.97Kb/s, asynchronous + FuriHalSubGhzPresetGFSK9_99KbAsync, //< GFSK, deviation 19.042969 kHz, 9.996Kb/s, asynchronous FuriHalSubGhzPresetCustom, //Custom Preset */ - + // init output pin digitalWrite(RfTx, LED_OFF); if(RfTx==0) RfTx=GROVE_SDA; // quick fix pinMode(RfTx, OUTPUT); - + if(protocol == "RAW") { // alloc buffer for transmittimings - int* transmittimings = (int *) calloc(sizeof(int), data.length()); // should be smaller the data.length() + int* transmittimings = (int *) calloc(sizeof(int), data.length()); // should be smaller the data.length() size_t transmittimings_idx = 0; - + // split data into words, convert to int, and store them in transmittimings String curr_word = ""; int curr_val = 0; @@ -503,13 +505,13 @@ void sendRfCommand(struct RfCodes rfcode) { //if(transmittimings[transmittimings_idx]==0) invalid int? transmittimings_idx += 1; curr_word = ""; // reset - + } else { curr_word += data[i]; // append to current word } } transmittimings[transmittimings_idx] = 0; // termination - + // send rf command displayRedStripe("Sending..",TFT_WHITE,FGCOLOR); //mySwitch.send(transmittimings); // req. forked ver @@ -538,7 +540,7 @@ void sendRfCommand(struct RfCodes rfcode) { Serial.println(protocol); return; } - + digitalWrite(RfTx, LED_OFF); } @@ -563,12 +565,12 @@ struct RfCodes selectRecentRfMenu() { // else options.push_back({ recent_rfcodes[i].filepath.c_str(), [i, &selected_code](){ selected_code = recent_rfcodes[i]; }}); } - options.push_back({ "Main Menu" , [&](){ exit=true; }}); + options.push_back({ "Main Menu" , [&](){ exit=true; }}); delay(200); loopOptions(options); return(selected_code); } - + void otherRFcodes() { File databaseFile; FS *fs = NULL; @@ -578,22 +580,22 @@ void otherRFcodes() { {"Recent", [&]() { selected_code = selectRecentRfMenu(); }}, {"LittleFS", [&]() { fs=&LittleFS; }}, }; - if(setupSdCard()) options.push_back({"SD Card", [&]() { fs=&SD; }}); + if(setupSdCard()) options.push_back({"SD Card", [&]() { fs=&SD; }}); delay(200); loopOptions(options); delay(200); - + if(fs == NULL) { // recent menu was selected if(selected_code.filepath!="") sendRfCommand(selected_code); // a code was selected return; // no need to proceed, go back } - + filepath = loopSD(*fs, true, "SUB"); databaseFile = fs->open(filepath, FILE_READ); drawMainBorder(); - + if (!databaseFile) { Serial.println("Failed to open database file."); displayError("Fail to open file"); @@ -602,7 +604,7 @@ void otherRFcodes() { } Serial.println("Opened sub file."); selected_code.filepath = filepath.substring( 1 + filepath.lastIndexOf("/") ); - + // format specs: https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/file_formats/SubGhzFileFormats.md String line; String txt; @@ -619,10 +621,10 @@ void otherRFcodes() { if(line.startsWith("Key:")) selected_code.key = hexStringToDecimal(txt.c_str()); } databaseFile.close(); - + addToRecentCodes(selected_code); sendRfCommand(selected_code); - + // TODO: menu to resend command/pick another file from the same dir? digitalWrite(RfTx, LED_OFF);