From fe212228e2a7b4649de73be940156ad3d4945111 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 12 May 2023 16:47:39 +0300 Subject: [PATCH 01/92] New SubGhz Remote GUI --- .../subghz_remote_new/application.fam | 15 + .../helpers/subrem_custom_event.h | 67 ++++ .../subghz_remote_new/helpers/subrem_types.h | 39 +++ .../icons/ButtonDown_7x4.png | Bin 0 -> 102 bytes .../icons/ButtonLeft_4x7.png | Bin 0 -> 1415 bytes .../icons/ButtonRight_4x7.png | Bin 0 -> 1839 bytes .../subghz_remote_new/icons/ButtonUp_7x4.png | Bin 0 -> 102 bytes .../subghz_remote_new/icons/Ok_btn_9x9.png | Bin 0 -> 3605 bytes .../icons/Pin_arrow_up_7x9.png | Bin 0 -> 3603 bytes .../icons/Pin_cell_13x13.png | Bin 0 -> 3593 bytes .../subghz_remote_new/icons/Pin_star_7x7.png | Bin 0 -> 3600 bytes .../subghz_remote_new/icons/back_10px.png | Bin 0 -> 154 bytes .../subghz_remote_new/icons/sub1_10px.png | Bin 0 -> 299 bytes .../subghz_remote_new/scenes/subrem_scene.c | 30 ++ .../subghz_remote_new/scenes/subrem_scene.h | 29 ++ .../scenes/subrem_scene_config.h | 3 + .../scenes/subrem_scene_openmapfile.c | 26 ++ .../scenes/subrem_scene_remote.c | 135 ++++++++ .../scenes/subrem_scene_start.c | 93 +++++ .../subghz_remote_new/subghz_remote_app.c | 181 ++++++++++ .../subghz_remote_new/subghz_remote_app_i.c | 28 ++ .../subghz_remote_new/subghz_remote_app_i.h | 53 +++ .../subghz_remote_new/views/transmitter.c | 277 +++++++++++++++ .../subghz_remote_new/views/transmitter.h | 27 ++ .../views/transmitter_old.txt | 317 ++++++++++++++++++ 25 files changed, 1320 insertions(+) create mode 100644 applications/external/subghz_remote_new/application.fam create mode 100644 applications/external/subghz_remote_new/helpers/subrem_custom_event.h create mode 100644 applications/external/subghz_remote_new/helpers/subrem_types.h create mode 100644 applications/external/subghz_remote_new/icons/ButtonDown_7x4.png create mode 100644 applications/external/subghz_remote_new/icons/ButtonLeft_4x7.png create mode 100644 applications/external/subghz_remote_new/icons/ButtonRight_4x7.png create mode 100644 applications/external/subghz_remote_new/icons/ButtonUp_7x4.png create mode 100644 applications/external/subghz_remote_new/icons/Ok_btn_9x9.png create mode 100644 applications/external/subghz_remote_new/icons/Pin_arrow_up_7x9.png create mode 100644 applications/external/subghz_remote_new/icons/Pin_cell_13x13.png create mode 100644 applications/external/subghz_remote_new/icons/Pin_star_7x7.png create mode 100644 applications/external/subghz_remote_new/icons/back_10px.png create mode 100644 applications/external/subghz_remote_new/icons/sub1_10px.png create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene.c create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene.h create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_config.h create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_remote.c create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_start.c create mode 100644 applications/external/subghz_remote_new/subghz_remote_app.c create mode 100644 applications/external/subghz_remote_new/subghz_remote_app_i.c create mode 100644 applications/external/subghz_remote_new/subghz_remote_app_i.h create mode 100644 applications/external/subghz_remote_new/views/transmitter.c create mode 100644 applications/external/subghz_remote_new/views/transmitter.h create mode 100644 applications/external/subghz_remote_new/views/transmitter_old.txt diff --git a/applications/external/subghz_remote_new/application.fam b/applications/external/subghz_remote_new/application.fam new file mode 100644 index 0000000000..4f633b9610 --- /dev/null +++ b/applications/external/subghz_remote_new/application.fam @@ -0,0 +1,15 @@ +App( + appid="subghz_remote_new", + name="SubRem new", + apptype=FlipperAppType.EXTERNAL, + entry_point="subghz_remote_app", + requires=[ + "gui", + "dialogs", + ], + icon="A_SubGHzRemote_14", + stack_size=4 * 1024, + order=12, + fap_category="Debug", + fap_icon_assets="icons", +) \ No newline at end of file diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h new file mode 100644 index 0000000000..d1559a7960 --- /dev/null +++ b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h @@ -0,0 +1,67 @@ +#pragma once + +typedef enum { + // SubRemCustomEventManagerNoSet = 0, + // SubRemCustomEventManagerSet, + // SubRemCustomEventManagerSetRAW, + + //SubmenuIndex + SubmenuIndexOpenMapFile, + SubmenuIndexOpenView, // TODO: temp debug + + //SubRemCustomEvent + SubRemCustomEventViewRemoteBack = 100, + // SubRemCustomEventSceneDeleteSuccess = 100, + // SubRemCustomEventSceneDelete, + // SubRemCustomEventSceneDeleteRAW, + // SubRemCustomEventSceneDeleteRAWBack, + + // SubRemCustomEventSceneReceiverInfoTxStart, + // SubRemCustomEventSceneReceiverInfoTxStop, + // SubRemCustomEventSceneReceiverInfoSave, + // SubRemCustomEventSceneSaveName, + // SubRemCustomEventSceneSaveSuccess, + // SubRemCustomEventSceneShowErrorBack, + // SubRemCustomEventSceneShowErrorOk, + // SubRemCustomEventSceneShowErrorSub, + // SubRemCustomEventSceneShowOnlyRX, + // SubRemCustomEventSceneAnalyzerLock, + // SubRemCustomEventSceneAnalyzerUnlock, + // SubRemCustomEventSceneSettingLock, + + // SubRemCustomEventSceneExit, + // SubRemCustomEventSceneStay, + + // SubRemCustomEventSceneRpcLoad, + // SubRemCustomEventSceneRpcButtonPress, + // SubRemCustomEventSceneRpcButtonRelease, + // SubRemCustomEventSceneRpcSessionClose, + + // SubRemCustomEventViewReceiverOK, + // SubRemCustomEventViewReceiverConfig, + // SubRemCustomEventViewReceiverBack, + // SubRemCustomEventViewReceiverOffDisplay, + // SubRemCustomEventViewReceiverUnlock, + // SubRemCustomEventViewReceiverDeleteItem, + + // SubRemCustomEventViewReadRAWBack, + // SubRemCustomEventViewReadRAWIDLE, + // SubRemCustomEventViewReadRAWREC, + // SubRemCustomEventViewReadRAWConfig, + // SubRemCustomEventViewReadRAWErase, + // SubRemCustomEventViewReadRAWSendStart, + // SubRemCustomEventViewReadRAWSendStop, + // SubRemCustomEventViewReadRAWSave, + // SubRemCustomEventViewReadRAWTXRXStop, + // SubRemCustomEventViewReadRAWMore, + + // SubRemCustomEventViewTransmitterBack, + // SubRemCustomEventViewTransmitterSendStart, + // SubRemCustomEventViewTransmitterSendStop, + // SubRemCustomEventViewTransmitterError, + + // SubRemCustomEventViewFreqAnalOkShort, + // SubRemCustomEventViewFreqAnalOkLong, + + // SubRemCustomEventByteInputDone, +} SubRemCustomEvent; diff --git a/applications/external/subghz_remote_new/helpers/subrem_types.h b/applications/external/subghz_remote_new/helpers/subrem_types.h new file mode 100644 index 0000000000..ffb2f8044e --- /dev/null +++ b/applications/external/subghz_remote_new/helpers/subrem_types.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include +/* +#define AVR_ISP_VERSION_APP "0.1" +#define AVR_ISP_DEVELOPED "SkorP" +#define AVR_ISP_GITHUB "https://github.com/flipperdevices/flipperzero-firmware" + +#define AVR_ISP_APP_FILE_VERSION 1 +#define AVR_ISP_APP_FILE_TYPE "Flipper Dump AVR" +#define AVR_ISP_APP_EXTENSION ".avr" +*/ + +// TODO: rename Filepath +//#define SUBREMOTEMAP_FOLDER "/ext/subghz_remote" +#define SUBGHZ_REMOTE_APP_EXTENSION ".txt" +#define SUBGHZ_REMOTE_APP_PATH_PREFIX "/ext/subghz_remote" + +typedef enum { + //SubRemViewVariableItemList, + SubRemViewSubmenu, + //SubRemViewProgrammer, + //SubRemViewReader, + //SubRemViewWriter, + SubRemViewWidget, + SubRemViewPopup, + SubRemViewTextInput, + SubRemViewIDRemote, + //SubRemViewChipDetect, +} SubRemViewID; +/* +typedef enum { + SubRemErrorNoError, + SubRemErrorReading, + SubRemErrorWriting, + SubRemErrorVerification, + SubRemErrorWritingFuse, +} SubRemError;*/ \ No newline at end of file diff --git a/applications/external/subghz_remote_new/icons/ButtonDown_7x4.png b/applications/external/subghz_remote_new/icons/ButtonDown_7x4.png new file mode 100644 index 0000000000000000000000000000000000000000..2954bb6a67d1c23c0bb5d765e8d2aa04b9b5adec GIT binary patch literal 102 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)I!3HFqj;YoHDIHH2#}J9|(o>FH3<^BV2haYO z-y5_sM4;GPjq%Ck6>60csmUj6EiNa>ORduPH4*)h!w|e3sE@(Z)z4*}Q$iC10Gods AV*mgE literal 0 HcmV?d00001 diff --git a/applications/external/subghz_remote_new/icons/ButtonLeft_4x7.png b/applications/external/subghz_remote_new/icons/ButtonLeft_4x7.png new file mode 100644 index 0000000000000000000000000000000000000000..0b4655d43247083aa705620e9836ac415b42ca46 GIT binary patch literal 1415 zcmbVM+iKK67*5rq)>aU2M7$VM1Vxif;vTv~W2u`S7ED{V3s&&L*<`XiG|9wd+THd> z5CnY!sdyuJtrvQyAo>KpiLcV|{Tkc)riAbluXfwSZCApL`ztB&p zx6LGKvks4K_4~)qD&oGa-YdJlW)hAKMNJd7<=t?6c^RI1>c$ifyjaM>^|&8!ey zB4!nh9u>5uen6Ve@<H5rru6h<2Ef#GQdQ*CmZOlQi~N!?9H`Rp;C% zU}CB21#?;r`&0|6C0}b-=jODa5|nEJ#ntxQ&{~jpgtwDta4hftr~G=#p@V36e4Zjh zq%J~{y26Jjn=1Nw-l*3%QW5YFE*v4z3gt0$&(*xf2en34c?JpH8+FYldo+Alvg8af-pG4(=!fyUi-Wsg z`g#n9VUcf(DFr{poMSNzw-lz>w+HV+n1ELr&SLA#LHUb0p(xWQ(1*vJ-i+1!`swxZ Z!O7;c$;lT_->m1Ovaz)0yuI`A$q$F8u*d)a literal 0 HcmV?d00001 diff --git a/applications/external/subghz_remote_new/icons/ButtonRight_4x7.png b/applications/external/subghz_remote_new/icons/ButtonRight_4x7.png new file mode 100644 index 0000000000000000000000000000000000000000..8e1c74c1c0038ea55172f19ac875003fc80c2d06 GIT binary patch literal 1839 zcmcIlO>f*p7#Yw)M6zw!O+@VZ{?d|D~WYi~8rHRY?X-&T}Yen`g$^+EJ;z+|RV zE@PoDvZ9%#+_}3bC_5Cj8jDGq541mi{7F+&KF}W65sr$Xn5H|YrMQ2(J7%Yc%;(zO z57ax000=TsQ+1Ke@+w#iw3au3cGGQWY740k2ijH>P(6tD)S)be>gX6Tj7`<`b>di- zgWp$8Y+?i31~CzF0&E4uRlA=C(Mp~K`{74jEchB|)4DDK!ZVhSwdFyw0YIZ1cDh0S{OvfO-U_~ zvmRF*m9sWDXNH)GOyqS1Skhxbr6}s*7t&@~kFM(NW5}qh?Lu@lJ}HE;FDiLdGO>LO z5pS*%E2grR)l^;|?O5b_?u0me&c1U}%jrk8*%=Wk%i)8yp2P|kuxmKg<=(u_`oQRI_0 zS`-DNysBx=#3&qSkgA@hJP>~D+ZM(s5jI6Owp`?yE=3e`YGUqkVOp#Cp=3wR3O4hX zX6BLsN3UBzV(vI5;|SZHgOb=HD0VFjpTyfFW}GnQuh>2*Q`k>*cAmA#iUT7EXSpo# zkPm5~#I-o^cpgfe#P$=4-Pi*SpT!-@nJgp8L347xe>5EKl`=_ZFc8XGy+_j=_R_7! z@vZZMowS1GJ?Zw)eetks%~G{BTR>T}9|jt0j3Btyb*C3-`C?fwY3EY`q*oYZ39DpM z&uJ;PCZPLs4QO1Jd_|A1PF)azZJ)RZ`^-VMWr6e#XUOA%3eLG_Ch@BDOHzMk*MF0G zCo7xMd?Mg*HMIXw%nNz?%60fZiZPlqb?GqUpXO`F&Yi!okZl(n>P@r1P2i)yk3DgRwbHeNn6e|;J^SK4TM LH~i+q&mR8;k>NTA literal 0 HcmV?d00001 diff --git a/applications/external/subghz_remote_new/icons/ButtonUp_7x4.png b/applications/external/subghz_remote_new/icons/ButtonUp_7x4.png new file mode 100644 index 0000000000000000000000000000000000000000..1be79328b40a93297a5609756328406565c437c0 GIT binary patch literal 102 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)I!3HFqj;YoHDIHH2#}J8d-yTOk1_O>mFaFD) zeWb+ZHz{mGZZ1QpXe09^4tcYT#4oe=UbmGC^A-KE*|F&zP#=S*tDnm{r-UX30HgpM AM*si- literal 0 HcmV?d00001 diff --git a/applications/external/subghz_remote_new/icons/Ok_btn_9x9.png b/applications/external/subghz_remote_new/icons/Ok_btn_9x9.png new file mode 100644 index 0000000000000000000000000000000000000000..9a1539da2049f12f7b25f96b11a9c40cd8227302 GIT binary patch literal 3605 zcmaJ@c{r5q+kR|?vSeS9G2*Q(Gqz$f_GQ#q8r!JE7=ytqjlqnNNGaK}Wlbolp-q`& zs|bxHiiEP0&{#s&zVZIv-rx7f*Y_O9^W67+-RF5;*L_{ra~$^-2RmyaK{-JH0EBE1 z7AVdru>JD$aK0bym%#uaXpT2Gcd#)x2azcxAABGV0BC)Aj-lw(6)B^^6`Y8RS?}DV z%)ko(See1!Eb3M$dL6)A6csaRjExg?k&xVzi*Rm;?iNJk#f=mkVEUR~jXN3dd|Lmz z;y}sMh%ol-?E1&`>dD;6jdps6NYoxN)s%@sf4~40YY6LAOtMEbwA4g#OCpANL823^ zSH66W05Hcxr$tg98gFntAOYL}xm$C;Skv&Ym?{TVR{)d(41vWacX1`7fM!jnW(lBK z26*WB#9I(Z1Ast!xEUC@Cj`v=urcBTdP`FWq=DYTy`}s>0vC{VzHdNRvxNFy}ir1|g=xDsrFP&l1P<-Sv zXLqYVYz{b^ZIV@1Ulg->7DEgvM*Min&Y8{8QW! z$_pA434?^wCTq$4%^>Zo8&|8XwbCv;KEd;WJJ{s;T}8R8Zwi7ssk$QWQ5l5+opKfX z;8D*COFEB#4W^*FIrRU%PDSc?B(}+9ZV?N9(yH>0uSnM?xg!>+>;e z{{7tXQQ|ZFXD*7q3XD!pwnih-=66+Qlqtl9;N-D|PHoI&B5d8>^V#i{mE>V0gQgu3+(DG%B z|8W!pl$lbQERt-0eZA%NSfvE4F>VAYP`DpeoF;Zm4`)2id;6xgSysWl6K$pWANcRZ z!ETRXKIU9G=@9lEB?<{ivj7!8FE9WN;qoo2Lr0#c@DmcF=JzU<73PmM3 zbe!-gs`c26Uc(AKz7%U!a0yZ5gsprdo1i51MjJPeHtV6d@Jy=*+_3dJ^>}p#8N#kPK_4t?hltq>u=?m+t z?em(Y%u3Bp_pyV?c_w-4c}p+?Y$aHr>TuPGs@SUj;Er!b@3GVLDS@T8OTts1JFS-p zKZ=&5zp;DRor*`Gy8MTeWdpVJv2(4-*slRM@XXG+i^F&Ku>7i08vKenZHoS4s(!!h zJE}*MHu7PR_IfdNzu*P}3^87K?f&A1;>NMsgKcR6**;aB74NC7tR(NB?{dHT-9QhXa*KoG!kGU1}$l2D>ypo)fSBuG$ zkTW4?+|I1m?6ZH8tD4^fB{cUpoEoZOo%4hl!EtNtQ#?j*jJR)x-Mn0TrxrX2uT_rh ziOh=Jxsktqbd9x{^s{c5z92Pk$LGoQl53o+=7QXXCp-Z>io998w|DCCCGfr20oiRN zX|`KH$W4)wN~)J$kYB~>4EU;NcS^qH&yzeUzXokpMegg_lX$6ve^4}%bY~Sg)%uJ- zZpb$p4x^GS5d{XJP=STbfpHV`58UBH& zKFg&BgS6bV+#-|^KBGeIBee2B zrM-`uTB^_(eS+{-KK1h3l`-Yjpv8X4z*uBwQ3a~pL0Ae2xvNGyC3A|#MARToe$W~8 z+4{DsyenENye9df1M}gNUM9_Leh6G=`9exL-cdSKQ_CGyEdZ3W5uoR!Lb^D)9!bd=7h@R=M%=|JqX9XP;Z6# zFD15Bw7qTP(ZlG?o@#x@=wG;XxM(>n@4P$9WwY#lW$h=`zMi_zq30HbV-zHheqpE0 zR6kXtxdzl&Ml2D#zDIvflJkb*e zIAI?GMjp?JBK76WW`{l{pFAY|%5?nYUxRnT&y6~Kz19AD;C0(z*7?dM{%HhVtqWEc z%+M$z6u@uQu)kg_%2PO_U|n1JE0V1>iVbekOLEOG$U6X^Umc519WC)L$t%`#Di0$ zY1|5H*440_`onhmXeayq`8EIg?x2r9KWe()q}QayqCMEC?c4meb4}#i`HHPaxO&3SPtSVKj@ND?Y+-@R`CDnf-d`T>vTn8RR<=@3 zNXk=Gloyh#S@3R89WHrXBHr;f(&ZO@I_Uo7;O5Bs@ecGx@7%7{_>Q`Adg&sCeZTYp ztVy{^vAUfOpTDzF*4`h%X0odWn`#uZ4s4igIV^UrVVg?c*{>K)hHq^^RxU2CM;WN> z;oK@^sg`J}BguyvilN{DQ*V+N4rD{X_~KAFj5qyk3(gP#cvSIDXe!zk3B!^InwV{j zCXGPmumQl(m`28618`K37tR+?goD{H>cAkpHyrG$XA89@o8$cOh%gGyG0e^h8y0{y z@CF+jfedLdjsO8i#eispKw=P#1_%GG3**eU%@8o?ZwNI24*pM2Xj=!6If;S;9nsX% zz(S!=&=CVoZ;TfP>*b{m(uQhlL7=)2EnN*L6sBVU)71t2^ME<-DBeCWl!etl&NwSL z*pEsj!yu5*&``}#9ZeF&7oufgU;u$?L$tLuI0%g(I+2Q@X%K^ye=Atvg0K`knTjV7 zLEDNLFH$fS4(5dVpED51|H=}B{>c+3V-OmK4AIhrZlCEl(AM_T0=zuK- zizjYd4*pHCwT0ObgQyrH7H4At2XjO;@px~TsgAA%R9|05PuEIcOUu&SOwUTs^00xK zshI`T;)sF%Z>|Li8%)3vslU12|K;lbk-Oav1Tx371&)Fb!FgLzNCeQ|r-tGG9E;W; z_5R^{|2Y=zKXM_QU?AJI{a>~IZQ?Z0_VnM@jcrt7jKN@*#$ZMzB}>VcEo(xFhBigA zRfKF&B$OpfLSqS8d&l#8dVcR8Z}0is_kGT}&h`CX>-l`{D|W}MM1o0W+qqCz&a@8xmO|M3uh;cln|6OUI z@X7fQ&dki(hqbDStcmq@R)<*FE(x{7@jPF^02^V5=v9ihMb|f1hw)0IhxkF_<1H_} z1sVWgmXE~@Wjrum=ebV>cmZ0s_CATm;a}mEc52Q5C=nO}OHAzGNx%Y4+73-pK+|sE zf&F7oVIUa*{8{JBz(BDGF#W^YNC4<9N*a&_dh_-a2?DV^K)SlsK3W zOCXnR0@miQE9D7uc?!4U4XYLag5q!qVkYiDSh|^JD*)2x1yFk>+xS2jzFcTm?NE^$ zEusR=1Jt#ow51*G(vhl2c`F}0KRYy{Jo3{2p&4FwzqpssC^#!EQ$-Rz!G~$z2>|jd zoi8@^jT0uuM~BC~Cj2=+8uB*%W~pE!<+;Jls%yObfcUWvPM_P@SPvhqk>^2RtzXee zpw9{L8C-GI=@-g9A^bLEC5ENHZn8J$mR*yf;vV50J7!cpZdF6S#2Ee38Kw@!gf4MU zH~T|ofioE<=_Pgf;Tvc0l%P^<+(Zk%8H}<#p|aT+abY8Ff9Htq!&92lSLbk7D(t{E zjjU(bM04fllo5%^3-CFm)D5AeU=e^FXGmfr{&k_>d3a+)aa}=xN$7&sHTfNh zfVj6VoV5%9Nwq8SCK^0ITUx;v0I2%9`_$cJSLF_4$)r9^g5d7-;)ha7k^2JBT`QGyenmoI!B!BgFZa^nPSIjjmHP5e8zHBct z>}g(M=h3f$4B-6LI6_z_Ow{YzNBpU4Q5No3aPn%6GK4Xlo>ROYK@oQ-NLryT2hS1Q z#~TwSIW2hlviM8?O9=^9I1CPTS9MyYOrlcISt$H6?B!qJq`S6dsv#09^-K@M!vvfq zTkX5@UgaFs(|?Idx+S6ai8fy!JtnNIngF-nVeN7Z`Pkld>>sQwike&!d8m z!q}j+#PS5O1l#Lt&96qwr4S9#BN(B)eb|Czi6eSM<1zl*H{oXKxy8rZigMly7Dpp) zp0Fn82H8REqlzST12a_HGG$OL1zP#tZ!<{Vq-7t-B%@O3Q}|wsw6|$peqXmwPE3aX z2;M0YDH7g@_E4AelRGO{xVu~ql8(6}@GdRA$pQKSu8{71L+l3C5qDtez&Yu}Hxem` z6sMHXl!;;o#{fs;ZdUOQhkK4<_f9*Vzhmk6*zQY_(0iGC-9?Iy&x;P0wqt{_@pc`@ z-STVPHZH9aL>@&(Sms8e^BoA~ujOKuWnROHb2zgex)a}&rr!-4kCTs9rZGVRYYIV- zvlx3+K(QCwE72=^{7f5<=%`? zl>Nr(;dCk;g6aw$Opx=3=@VvK69`}ZZjdTEXD<)m-PPh#nON_W-)WuySB2X5DDN+N zOj#o@Hg%5&TlX_@z|RoxL4x-e)E6|2*6eRf_RH|9>@0i7Xl-rM9ANjdo2TOpy0iRp z@HHQ+`qyJ4Zd+tE9Emv?)0oNb81R+irnMuZ>Qj# zxib@y+4A&mNoGlXP$qd$YD6l2f7kv+drBW{dVN}WI%9gX}>;*m9J4X{*B+`P?WbMg?R|_dOLt0YC zJHiM_Ty3A^GkR^rdo$!_RLz|l@F22ACA23r zJ#_ne&f4MCmW}wIwZp7=nYm*E?mRDe#(1hP%3plU=f|hSpU!`KyPiO-!1Ha8okr4T zJB37Cl;}y+I@x)J6@t!yw`NAC^c%r!=@Sa8&{j3f-kx1?ksX4A;-S<#E11dFr-IQ# zR{qfyN+h{-*_HEB`wzg2wZ9!NvuB)PENk|#M_tyutK;V4i>^I8-0%C89^}pT^~d@X zrZX$TDvB#EGNXQ4%%w>%B=-r;Tp6wJtw&z@62Lp*pP`dAn&FVjAe4>`?UC_VILOQnvfFm7kYb}KIe$4b!q%cDFE;P^!}5wFhS$flol=(c zKOH`gTJ?#vwG4c%BV>!!U?s|3f2Oiv<7D3Rncea6%ttMQ=SEEn7*BSKM z{I;U9VyY&6%QWwRxn-WhQPHJ&t+6%>}7+sVXoLpPbO)$>wJq(%cIl{yAd4L zao(3TFdv5v@49^(rE$qwH>D`KxrI{ti`zebVW|0ofEcHjRC^^ydT1 zit!QWV{YB&7Fp!JzRyR>-^@&*rwXPh>}8kQ`$wvMO}pPl&We;M%*Bo=xRH;1X50$# zU5slhYkSkir-#>@IobM@-9LZpVE$4__664#r;U<(Fif+aek4~_5ISPczF+n%G&YJPZd_dwhcM)XK$a~zGT6f@?}u{2kzI_J`y5h z5613ABWPopVbs3NnT+5kv=awJUz(1+_-pXaxwBvFzTRqoHSnr!F#SULqTm#orO}0` z4PcuJ1W{iBF zKEPVWtf%|A9(S$wMs?&E%QC)W%H5Wm7d}tKyUte8et?%f`c=!1mLN-!R-v?wVf6iz z)G6X}%Z#&ODdUID)ZtFfy9=wnb=?6Uetyt)y~(QPyq;Dlr>K3}Q=wY9_%mo}MmAXZ zJ7&N&B%XPHy{2#D+xAtlZx_lo9}?@xLqFZ?+&f;mh;c-PqH;Eqf4z$u?y_pN>Q=E- ziH*-zQc@6+ub%g8PZ}Rf89BiysN>^Vu*|b~eTqQIXzO`L8nmD()4q3juuoh;Z zx{Lc)DaWwDG3=>cj9@&S2$*_OJ%}J{GTxhrCE`61Z>_G%gwd42_vIJi(910C^C-NfacQ^Sl-eB6%Xg&U!Xb8ybq}LqdnpiS{AK90(zP z1Ord7u@T6SiQp2Di3~i5N%p4%Aecz--@FL!dP@uegZ@@w_#wgnaSCT+2SQQlM9?8^ zm=*yFg@O(lXcIm0a1R|XJV6r#hr(eH8234(1v`X*>mXnTpnnFKYmn~gg}|Cy{$q~2 zLxO!63>pFg2@Vd{4%X48(!C)t0|NsH6b^yIwYVBu0W1mw&(xv>sQhLyCk7DcBpQQ6 zrGT~=@gCGb1`^D5_CHaOY5&qv0{+PqH)jwgo(6$wL${*(t!QKO|ErS8|7r&?u*CoR z`+pJ#IIw6$2$mQ?4WtvewewQhGDSn6=tMk&N_U`A{eLIY&WFmN2KZ2EAh?b;45V&@ zCy*#xlKp=}Y-|wLlmG^vLLge3Bf(q}Z4${7VPJ`Z>caJO59#RW!C)3BeO)*VWoc## zg<9yK4D<|sW6i0AKr)fS_>J}aFIMl5*sX>j)3}z+iF8sB(bJMnC4>Hs8bSKAFYrI| z{e$)VvoAV-#6q~vK(=c8ziRzk#BHFh<-g6#-Td4BL<+a(>D=bN76lY@FUB@IjDy9m z(5*YN-4s*8oj}&+rVh+L4|neH1o$j1E!71)pl~xe=$Un0lQ15DzW@MRrx z!J?<(q3pT2^$+V+Q`u7+9n4PA$lc;2p&F8~jx^B8sR zx>rCR%LJ^+TUW{z>G}+2%^g|I2L#7s6GcrtfXECp^)>*c&kdOGlW6Awp?LDNx@(7v z-Ko(PNG_nRHMKqcShu!hMe19*kj44oQKivW0gudZG6%)H1;)YI=~>DW$SEFFhY$eB zt#!TJ(l<_=nj9aQ^qvY}e{aa&@}H-Gjg%IKwyLgi^8#Xao$P-1iHTkwY7^JPpj!Xp zlR&>S;5)SDrad5#cS7)O=vpjOf5T*7?k#k)p~7ClUAyK~Ja1KNjl~-M(jK7<$40Dh zzHSYK&I4yMO)^UA3Zgd8;K;$HnE0tyUNb0pbxL`wDf--I{K2kKokyqCrLHbuuT-GH zwoT0Em?R6Omef)4>2t6J#k5U<Kzn-O7ywj#*>mb{iVUie9{?=!&L4Vcx>M+-B&$v&`=vrv zoeVc_hlPpI{yIZ3vmN7+dj)UpNi&sotb_OQK7Gg|m$y4}M6B#3R9|>%Sp3xa8LG?< zk3G4s_EcRG;5BXLm%u5(V|IJS_klb3WisMb#kh|E-FUbw5 zyr@BwG>AK8@-uOu83en!aka`CnsWZ}ah~_wK_<`dD#~4L%nR(I>xjBVrsey0$(8Lx zL_W(e>N@r%hz^8bjmJlJK}Ec;eZ-x*cG=S73RX_FNg6+a)pbtL#VcSB2TRG<<>J`< z`?+HyC1&|gUle;4a3L|#8jHf3-&L7aE)%chcM*uX2z~VjIQg!9nM$bmT0O%P{wNV^ z#ZvvIv`;Bl<@6sS67I>!{UR;b$L$1_R1#q}yKMZC14xZRheD%nF=94KbtaM2@_C&9 zaU=_ro>ZPFnrMH0z2)_Ixg@+HW)vlmzaLYWB7RhtU_8Nl`zFjRBk$hv_Tt?4{P$wu zH&57*@`BM2hs(thIzgE#?OD?1t%Vu|J#RCKKEzdD$TYoD;8WB-%k;PD-Tq&8PESoo zeGd^5z9bygg!DWh>o0p&wrEeeEF=SUhwoi_Mzf>V2bg?@&kfNV6esMVl|x}tNpHkc z;i=B45vf!69GwE4jC+{(b~)a661{)gIsA^5(-ZVqvA}!j`#r@9PA`h}N;@zim;`j^ zarc56_st7G@xqTUMO)=vLKZmU%Nu3ml%yMBgaxcwFU^@}M&190t>?+dYqO|ezIFLv z$XS$wdEh;7mUohO&g7YPE|JDZ!}A6ovyXNtbqIHy)!@-E)_BzGSK?g~QF6FHw7;g` zbB;DAJvYm|wtK=twSZHf3V{x^sfUGo=5?(S~&txT%-E$Ff-_@hGg+hw0I zU51R2H;b~@lcn>SFz9cH^CZFs3hN6S#%m6?r}$@jS9X=Xqqns+s}HjJSS_>h20hvS zxwx8-RRbGw(YGzL8;-{6#Wtn&r-ilhrP-#fvTisVIWwJ?oj*D(2*V8UO@;O6;BUNmvJB!T`eNt3~f!F zko#8I{q)^(LDq|`!IF=p_n+Dj4dM6KZ8fvxTijkF*rwm-SFxjK+QxE!oV zwhoA?P$bG`$gG7+9y|oQr}_1GnFIX{eO0}eHSW6ZQyssMP<-wAkpaJFv|t~WUjQZm zKbut%S#hu8Jmc~Y%Y}4ty2O5gxhv!Kef5YdV}aaL0h!v_-oUDw1g{pcIw>5q*kqCjS7$R7KNBC@T5#Nx%QXnV_={J8w%kIE~K8eX5waZX*) z|8ykW{HO0Fd#j*EZ2^0X8Z$}u`g7$aTW5>j&#camXFh5eq-3XL7hr^mX=Q33w8{^Z z+k302B@2%;CrNMQlP|wn9amlpTpExHh(>i4lwnHIBGM?xT{XtZJtr9z$ZF(?_u50= zTVL0dcU_PUt4@4~u6X#QuY%#aFbuA>d?BqI>mU=N33bC%dNGLe-Qlgit&h_-(W6+5 z)1n`9a4{Ye)qVT6x!MI6oz&u#mR54<_Y=?YQn*wvC$?XD&q?QVhh$RSSya~D(jO14 zDkeu=?A&|8mYJmf{?A9t-^|S*X9{P?tX0?A2S=;@Oncs5ninpSUx=HKcPAbFOurTC zw;bPI*8ZlQM;E6%ce3pnYhdw~UcpLe&N;VM=gpG)B&9!VE;HmQ^~52OSEds${}{Rxc6JQ?81X)1 zkhzN5$nbYN?pEz%-kEDGL;r>k0huQ(;>hkkyMz>yZX3 zyE%WAvUE!<-GSmw55dt0fT1NJfC!FKWRcq89?}qHC*VOEo9>5|N=afxKLY%hDXc9TWKN+GK!-J< z8h9-&Ezn^DO@bE==Be$C!>fZ}S}-UC%DE3~Ko7%V+Hj}==hG=V2Xg(0Afq?-;3kHF~G&l&2Kqi@vV`z{Am47Q(5CZWuB9%_0 zkU`suI8RCt9RcQ;{c9E^>OZpNz`s|Dvt|$mjtYTlYHiQzH_+Dh|A&%D|DXfu7{Y)3 z{;P1HBa=#iUSh0fZq#=_NCA%fxZ+f2&SzG1s$-( z;fdt!$iY7;wzhB^av&W?#uIET5MYjoCXwg`*VTsV=^4Ou4x5@;LZO!CW~Mq82B!L! zmXcl{>#<7uV}wy!_2I{hwS2#|&h9Z~xC;{|<2qXuJDQ@p163R|OV+mP%$Mbu7e(xV|@A;f_?)$#(@ArFM*L_{*^EuaSt<44aW%vOA5U@a* zpxNW@orjl;{a(6JI069tNCFaRYk@?9C{(g1!4D4r^!{wSAWYJ#g#OSfUdYk7Z~k$b zUjzVFWb!r(JLd`C1hAKdMGPCGqWK-g#P?;P92ze5@T0P$M{^HVdKq1hJ{{w5R_D9? zVByoyVAkB+#>b87sjR8Z4o0U?_&yQk#K}A#Ko=dQ2k(=Qw?Q?u)P!@2qlURb!jrA9 zym%S`V4jOX52HOY*yMOf1~>sqkNQE8rjcKfRkq4b04Na{28&GX;YdIO&Fc2eVnDML z@W}3o2S1Pu0Dg=RV=z!G0L=cd(B}dAijoE;fxf)`MZ7>P2atZq{2-^{3&71G0q|Mpou9$XIm2ssfWSCRf{>vb5T0(V+6I7hI057V(RMD7C0DLScinK2 zD?A8>kOnE00v^YOJsxbP>@3Apf^02Tc-#9ocEmKhxHN|Dwu@?Yj z*1BG9>lh?VO^%ODdQSPVel+H7`_7ZW`U(p}+toKXxdCD8PFBC`#6&L_rHSKFK%H;V z8KB=0@E%%o(H!8*J5H%h`P41Gq#yx+dBvvQ`q}QMt$y`k-#IvA1To!#fMM8@+6|dK ziGZ+|7L2h907-Rg@rEiKKzmxj7ywj%l{$MrS<>~E)&DO2kZ5OjdzWQ@8`cGm1-nyUk~r&e)@<@CU;-Ph;aE!sE)wYu*lhn8H(gC zH>sRgQq@=ZxQ&{5MX?I-=zZ>Sec%pW$@DmGFczhCGrRya9W8bW+}KPl;4CusNpwLe zE~-(*bYssNt|tsMgJ9P;uUDHxlOxJbaed$nFnoSrUgr9nT>mbbmXJ$$YMyVGO!)ys z__Msiu9IH_Xh7)oI9zxaRM7LrC+yi9S54inVPuq>BybZLZO3?RoE+v@ptx*(4wl7x zkTWJ+be8wrW#LzTml6`pF_swQeWh8&a*--tC%(wb&{uzflkVG;D+PY9W)DA;my+?roODFJ4&$HEsifKn^4E70#2CS+ME&m<6AzKrvh zg)>2Ei4_S#2{t!3T3(M=h`}49M=kmC4x$T^MNVkr4JNqn-i8^c=N6x8FUtAATO19) zecFPU8)yr$yILfw6_BCSo+*KBEl|tvd6z-(BCL8trfF4tpCb>LroBt+_WinhdTKiI zN6=n@D*};CDEC9szS0+@3#BTgA?cR)c;2U_H`{A`gvq9R-4eP*cEB82IT9kC_*NtZ zp5mAimNHdr@8IuX(8DO+WB<4uOsfYFugtYL9z;N<2%#N{;mh_t*Bj z&r##I1#=Yz*lv&>Qq%!)j&Y!H~sgx8OAi<^4n#>>Cau}%fuh~ z%aY$%y{sVeJJsJo_FjVEG`#x$k&r-rohq*|q}GH*HRJ2D)X9X~QHde6?N&JcT@{A^{N zGWTY}Gh3hCFUc%v2+Sl7iH(ZIAMQT9Y)9&c&Th`~&t}Z-n$umut|+Y#S32d|_KV2% z9;Y1-q0$1{0{tk}GX*1BuZtRrUQauD$$H)K&tB4&ymvC8RU|DiP1257c)gHxJGeDv zLgsr__tW>w`I#>=2TMK?KYVUOG=@Iduu{*IZE<;xU>W_GU&V}`ZyU=l%q)DhlrRN3 z7kJM3+(yj-n2aZ{3RjSvSI1lvuFlapQQ&F~Lz2ArtY0%a==@JDvOPZf%}eo)^0yd-cVQ z_wori%Ttrc^^%LSYdFn8FV&1L@wdF$;-_WTHQJOd5A^PfyVA)!BpgP*w`Mur_KY`r z*xWC=Ql224F1Z#ecK8UaSpD0nay#02+Nx?VbKH5ut0rzCzUapD;{!g=sDWNgA3wAo zZZ@+ryt245f`0X<=|Y+aP4pn&+_mwBz6Qj#F@Me}zYNW+@eKP^8m@F=Fz>nK*pdK?zI9eHHo{sWbFSR1NC%2hAbR z?Qd&}doD?Y)FeEzt$g&PuafS(Fbu9UeIcP3V<#D;4s}6SdC&>--Jz}Ct!1fOwxbxd z!=evka4`-Y*?speQst79R!UKFODn1L$LZ%dacqi*1Is6^=ZxdUBa$huObYXU>CZ=I zm6M}R)~-Dv%M4z$6*gRk3%(l1sl^Uk0cD&6q9 z0H#_#F&A;ChV}JEezx2>IrG|zUtuih7%remJKiZLH~SD`VQu_U(paHKVNSNS0pdgY zAY;{XGu_waluL~lvNOj(lJ?!Q!gaM}>C05S%X~HE2YA(eK&j$n38EBX9!A+3K|MS} zp24rS&N=Co(tcRY9PeVizqsyG-{b%B=SOvy+l(64n_1ZklJe*Ml}c61KLc0hB!l?B zTMoJe$I~Bf*7k3G+r2LI?PB@%V|+bv_@`UFTjy(MA(kND)tv3*U+=Gubep%C_b8ev z#>QvM%gYML)GT^*B#ji76^eGg4Rid(nDKuwHMBLlak3M$**CvuEvB=slu@)qWj!c* z2yaqslCSPyAQtXzmUIk+vMO0sLrpdE>4!EAw{4fY)^SaR?`&4}r$V+jA*+{{Ho|q4 z_ObserD>)ZnjP7b7KEkZ0V5BxJ04^~#CqY;c&rEGd<$L=0Jshj>@hTql_eZUCaPn1 zFzR$7h0O*4Jp(!gi}S_PK<;=i0to?Ty{H3&2p$NqleU$H6$Od+CZK|;c)MV0dt9(D zPS*o$pbyfc!`T8vJPiw?6a7g3a5@6~w=SGL-!VhLpuZtBUj+C+L1CCCs^dMdFn3K)EKU^!(||!CQ1*RH4SEa?(}Y8HLH}G}wnM6iCmd~J_K!RE z3IX<}(I{{TBq%6IJxEiXO!b05b#-+i8ZZb9rp897`7=l~EM1M{ulQTR1n-Zd5-2nR znFQKV#JZCMXb3Pn*#Bffr2H#O^8e?g*k=ZzV<`}*y2egczkya(|38#S{1@#{L*xG& z@Bb<6Z_l9MA!ximIe>~|*UnRM#}x&Rq~ftOGS!|;_WOO1w%%kK+25N?0l_rYp`b%n zSR8@0V>$dc#mWk9LGq_zNjSWP2?ER(Q6~^Q;7Bc`rjaR9`S)2BNHb$2 z4GmLGq^`E^Z>|X$7eK_5Xur80|K%S2BX_4Eh!nPG6Fij=i1#p~l8K~IZDKdj&h+2rWiS41e>{oZ^Hg?oM~n|nus@7lwwCs$ z?D1C^P>lR^nmv=VFfp>H_q)5fd2lQ2GLzyiQ{d*V|Ea<2ASCPtaP|Sxo{WhCHW08d LwKgd=cDwXHDN#*w literal 0 HcmV?d00001 diff --git a/applications/external/subghz_remote_new/icons/back_10px.png b/applications/external/subghz_remote_new/icons/back_10px.png new file mode 100644 index 0000000000000000000000000000000000000000..f9c615a99e69c0100b03a9ae7b2df903da4ecd66 GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2xGmzZ=C-xtZVk{1FcVbv~PUa<$!;&U>c zv7h@-A}f&37T^=&`v3obAT#vPO>_%)r1c48n{Iv*t(u1!X;5977~7Co?ed rv9U?Av01aVRT(gMJdt+jXk=uN>R^g!*w%ImsF1<>&pI=m5)cB{fFDGZlI8yr;B3<$MxhJ?+;A4eL&#) z0Ra}bue?07WhLz78x$BO|L3mq-MMxdP^D^#YeY#(Vo9o1a#1RfVlXl=GSoFN)ipE; zF*LF=Hn1|b&^9ozGB8+QQTzo(LvDUbW?CgwgE3G~h=Hk + +// Generate scene id and total number +#define ADD_SCENE(prefix, name, id) SubRemScene##id, +typedef enum { +#include "subrem_scene_config.h" + SubRemSceneNum, +} SubRemScene; +#undef ADD_SCENE + +extern const SceneManagerHandlers subrem_scene_handlers; + +// Generate scene on_enter handlers declaration +#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); +#include "subrem_scene_config.h" +#undef ADD_SCENE + +// Generate scene on_event handlers declaration +#define ADD_SCENE(prefix, name, id) \ + bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); +#include "subrem_scene_config.h" +#undef ADD_SCENE + +// Generate scene on_exit handlers declaration +#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); +#include "subrem_scene_config.h" +#undef ADD_SCENE diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_config.h b/applications/external/subghz_remote_new/scenes/subrem_scene_config.h new file mode 100644 index 0000000000..93d4de642e --- /dev/null +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_config.h @@ -0,0 +1,3 @@ +ADD_SCENE(subrem, start, Start) +ADD_SCENE(subrem, openmapfile, OpenMapFile) +ADD_SCENE(subrem, remote, Remote) \ No newline at end of file diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c new file mode 100644 index 0000000000..8e651a5347 --- /dev/null +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c @@ -0,0 +1,26 @@ +#include "../subghz_remote_app_i.h" + +void subrem_scene_openmapfile_on_enter(void* context) { + SubGhzRemoteApp* app = context; + + if(subrem_load_from_file(app)) { + // if(subghz_get_load_type_file(subghz) == SubGhzLoadTypeFileRaw) { + // subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWLoad); + // scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW); + // } else { + // scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSavedMenu); + // } + } else { + scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SubRemSceneStart); + } +} + +bool subrem_scene_openmapfile_on_event(void* context, SceneManagerEvent event) { + UNUSED(context); + UNUSED(event); + return false; +} + +void subrem_scene_openmapfile_on_exit(void* context) { + UNUSED(context); +} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c new file mode 100644 index 0000000000..787a717608 --- /dev/null +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c @@ -0,0 +1,135 @@ +#include "../subghz_remote_app_i.h" +#include "../views/transmitter.h" + +// TODO: +// #include +// #include + +// #include + +void subrem_scene_remote_callback(SubRemCustomEvent event, void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, event); +} + +bool subrem_scene_remote_update_data_show(void* context) { + SubGhzRemoteApp* app = context; + //UNUSED(app); + bool ret = false; + + subrem_view_remote_add_data_to_show( + //app->subrem_remote_view, "N/A", "N/A", "N/A", "N/A", "N/A"); + app->subrem_remote_view, + "UP", + "DOWN", + "LEFT", + "RIGHT", + "OK"); + // SubGhzProtocolDecoderBase* decoder = subghz_txrx_get_decoder(app->txrx); + + // if(decoder) { + // FuriString* key_str = furi_string_alloc(); + // FuriString* frequency_str = furi_string_alloc(); + // FuriString* modulation_str = furi_string_alloc(); + + // if(subghz_protocol_decoder_base_deserialize( + // decoder, subghz_txrx_get_fff_data(app->txrx)) == SubGhzProtocolStatusOk) { + // subghz_protocol_decoder_base_get_string(decoder, key_str); + + // subghz_txrx_get_frequency_and_modulation( + // app->txrx, frequency_str, modulation_str, false); + // subghz_view_transmitter_add_data_to_show( + // app->subghz_transmitter, + // furi_string_get_cstr(key_str), + // furi_string_get_cstr(frequency_str), + // furi_string_get_cstr(modulation_str), + // subghz_txrx_protocol_is_transmittable(app->txrx, false)); + // ret = true; + // } + // furi_string_free(frequency_str); + // furi_string_free(modulation_str); + // furi_string_free(key_str); + // } + return ret; +} + +void subrem_scene_remote_on_enter(void* context) { + SubGhzRemoteApp* app = context; + + // TODO: reset custom btns + // keeloq_reset_original_btn(); + // subghz_custom_btns_reset(); + + // TODO: init view data + + if(!subrem_scene_remote_update_data_show(app)) { + // view_dispatcher_send_custom_event( + // app->view_dispatcher, SubGhzCustomEventViewTransmitterError); + } + subrem_view_remote_set_callback(app->subrem_remote_view, subrem_scene_remote_callback, app); + + // TODO: notifications + // app->state_notifications = SubGhzNotificationStateIDLE; + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDRemote); +} + +bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { + SubGhzRemoteApp* app = context; + if(event.type == SceneManagerEventTypeCustom) { + // if(event.event == SubGhzCustomEventViewTransmitterSendStart) { + // app->state_notifications = SubGhzNotificationStateIDLE; + + // if(subghz_tx_start(app, subghz_txrx_get_fff_data(app->txrx))) { + // app->state_notifications = SubGhzNotificationStateTx; + // subrem_scene_remote_update_data_show(app); + // DOLPHIN_DEED(DolphinDeedSubGhzSend); + // } + // return true; + // } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) { + // app->state_notifications = SubGhzNotificationStateIDLE; + // subghz_txrx_stop(app->txrx); + // if(subghz_custom_btn_get() != 0) { + // subghz_custom_btn_set(0); + // uint8_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult(); + // furi_hal_subghz_set_rolling_counter_mult(0); + // // Calling restore! + // subghz_tx_start(app, subghz_txrx_get_fff_data(app->txrx)); + // subghz_txrx_stop(app->txrx); + // furi_hal_subghz_set_rolling_counter_mult(tmp_counter); + // } + // return true; + // } else + if(event.event == SubRemCustomEventViewRemoteBack) { + // app->state_notifications = SubGhzNotificationStateIDLE; //TODO: notification + scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, SubRemSceneStart); + return true; + } + // else if(event.event == SubGhzCustomEventViewTransmitterError) { + // furi_string_set(app->error_str, "Protocol not\nfound!"); + // scene_manager_next_scene(app->scene_manager, SubGhzSceneShowErrorSub); + // } + } else if(event.type == SceneManagerEventTypeTick) { + // if(app->state_notifications == SubGhzNotificationStateTx) { + // notification_message(app->notifications, &sequence_blink_magenta_10); + // } + // return true; + } + return false; +} + +void subrem_scene_remote_on_exit(void* context) { + SubGhzRemoteApp* app = context; + UNUSED(app); + // TODO: notifications and reset KL + + //app->state_notifications = SubGhzNotificationStateIDLE; + + // keeloq_reset_mfname(); + // keeloq_reset_kl_type(); + // keeloq_reset_original_btn(); + // subghz_custom_btns_reset(); + // star_line_reset_mfname(); + // star_line_reset_kl_type(); +} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c new file mode 100644 index 0000000000..0ad9837e98 --- /dev/null +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c @@ -0,0 +1,93 @@ +#include "../subghz_remote_app_i.h" +#include "../helpers/subrem_custom_event.h" + +void subrem_scene_start_submenu_callback(void* context, uint32_t index) { + furi_assert(context); + SubGhzRemoteApp* app = context; + + view_dispatcher_send_custom_event(app->view_dispatcher, index); +} + +void subrem_scene_start_on_enter(void* context) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + Submenu* submenu = app->submenu; + submenu_add_item( + submenu, + "Open Map File", + SubmenuIndexOpenMapFile, + subrem_scene_start_submenu_callback, + app); + submenu_add_item( + submenu, "Remote", SubmenuIndexOpenView, subrem_scene_start_submenu_callback, app); + // submenu_add_item( + // submenu, + // "ISP Programmer", + // SubmenuIndexSubGhzRemoteProgrammer, + // subrem_scene_start_submenu_callback, + // app); + // submenu_add_item( + // submenu, + // "Wiring", + // SubmenuIndexAvrIsWiring, + // subrem_scene_start_submenu_callback, + // app); + // submenu_add_item( + // submenu, + // "About", + // SubmenuIndexSubGhzRemoteAbout, + // subrem_scene_start_submenu_callback, + // app); + + submenu_set_selected_item( + submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); + + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewSubmenu); +} + +bool subrem_scene_start_on_event(void* context, SceneManagerEvent event) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubmenuIndexOpenMapFile) { + scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile); + consumed = true; + } else if(event.event == SubmenuIndexOpenView) { + scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); + consumed = true; + } + // } else if(event.event == SubmenuIndexSubGhzRemoteProgrammer) { + // scene_manager_set_scene_state( + // app->scene_manager, SubRemSceneChipDetect, SubGhzRemoteViewProgrammer); + // scene_manager_next_scene(app->scene_manager, SubRemSceneChipDetect); + // consumed = true; + // } else if(event.event == SubmenuIndexSubGhzRemoteReader) { + // scene_manager_set_scene_state( + // app->scene_manager, SubRemSceneChipDetect, SubGhzRemoteViewReader); + // scene_manager_next_scene(app->scene_manager, SubRemSceneChipDetect); + // consumed = true; + // } else if(event.event == SubmenuIndexSubGhzRemoteWriter) { + // scene_manager_set_scene_state( + // app->scene_manager, SubRemSceneChipDetect, SubGhzRemoteViewWriter); + // scene_manager_next_scene(app->scene_manager, SubRemSceneChipDetect); + // consumed = true; + // } else if(event.event == SubmenuIndexAvrIsWiring) { + // scene_manager_next_scene(app->scene_manager, SubRemSceneWiring); + // consumed = true; + // } + scene_manager_set_scene_state(app->scene_manager, SubRemSceneStart, event.event); + } + + return consumed; +} + +void subrem_scene_start_on_exit(void* context) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + submenu_reset(app->submenu); +} diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_new/subghz_remote_app.c new file mode 100644 index 0000000000..d25e65ce71 --- /dev/null +++ b/applications/external/subghz_remote_new/subghz_remote_app.c @@ -0,0 +1,181 @@ +#include "subghz_remote_app_i.h" + +static bool subghz_remote_app_custom_event_callback(void* context, uint32_t event) { + furi_assert(context); + SubGhzRemoteApp* app = context; + return scene_manager_handle_custom_event(app->scene_manager, event); +} + +static bool subghz_remote_app_back_event_callback(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + return scene_manager_handle_back_event(app->scene_manager); +} + +static void subghz_remote_app_tick_event_callback(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + scene_manager_handle_tick_event(app->scene_manager); +} + +SubGhzRemoteApp* subghz_remote_app_alloc() { + SubGhzRemoteApp* app = malloc(sizeof(SubGhzRemoteApp)); + + // // Enable 5v power, multiple attempts to avoid issues with power chip protection false triggering + // uint8_t attempts = 0; + // while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { + // furi_hal_power_enable_otg(); + // furi_delay_ms(10); + // } + + app->file_path = furi_string_alloc(); + furi_string_set(app->file_path, STORAGE_APP_DATA_PATH_PREFIX); + //app->error = SubGhzRemoteErrorNoError; + + // GUI + app->gui = furi_record_open(RECORD_GUI); + + // View Dispatcher + app->view_dispatcher = view_dispatcher_alloc(); + app->scene_manager = scene_manager_alloc(&subrem_scene_handlers, app); + view_dispatcher_enable_queue(app->view_dispatcher); + + view_dispatcher_set_event_callback_context(app->view_dispatcher, app); + view_dispatcher_set_custom_event_callback( + app->view_dispatcher, subghz_remote_app_custom_event_callback); + view_dispatcher_set_navigation_event_callback( + app->view_dispatcher, subghz_remote_app_back_event_callback); + view_dispatcher_set_tick_event_callback( + app->view_dispatcher, subghz_remote_app_tick_event_callback, 100); + + view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); + + // Open Notification record + app->notifications = furi_record_open(RECORD_NOTIFICATION); + + // SubMenu + app->submenu = submenu_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, SubRemViewSubmenu, submenu_get_view(app->submenu)); + + // Widget + app->widget = widget_alloc(); + view_dispatcher_add_view(app->view_dispatcher, SubRemViewWidget, widget_get_view(app->widget)); + + // Text Input + app->text_input = text_input_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, SubRemViewTextInput, text_input_get_view(app->text_input)); + + // Popup + app->popup = popup_alloc(); + view_dispatcher_add_view(app->view_dispatcher, SubRemViewPopup, popup_get_view(app->popup)); + + //Dialog + app->dialogs = furi_record_open(RECORD_DIALOGS); + + // Remote view + app->subrem_remote_view = subrem_view_remote_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, + SubRemViewIDRemote, + subrem_view_remote_get_view(app->subrem_remote_view)); + /* + // Reader view + app->subghz_remote_reader_view = subghz_remote_reader_view_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, + SubRemViewReader, + subghz_remote_reader_view_get_view(app->subghz_remote_reader_view)); + + // Writer view + app->subghz_remote_writer_view = subghz_remote_writer_view_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, + SubRemViewWriter, + subghz_remote_writer_view_get_view(app->subghz_remote_writer_view)); + + // Chip detect view + app->subghz_remote_chip_detect_view = subghz_remote_chip_detect_view_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, + SubRemViewChipDetect, + subghz_remote_chip_detect_view_get_view(app->subghz_remote_chip_detect_view)); +*/ + scene_manager_next_scene(app->scene_manager, SubRemSceneStart); + + return app; +} + +void subghz_remote_app_free(SubGhzRemoteApp* app) { + furi_assert(app); + + // Submenu + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewSubmenu); + submenu_free(app->submenu); + + // Widget + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewWidget); + widget_free(app->widget); + + // TextInput + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewTextInput); + text_input_free(app->text_input); + + // Popup + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewPopup); + popup_free(app->popup); + + //Dialog + furi_record_close(RECORD_DIALOGS); + + // Remote view + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDRemote); + subrem_view_remote_free(app->subrem_remote_view); + + // // Reader view + // view_dispatcher_remove_view(app->view_dispatcher, SubRemViewReader); + // subghz_remote_reader_view_free(app->subghz_remote_reader_view); + + // // Writer view + // view_dispatcher_remove_view(app->view_dispatcher, SubRemViewWriter); + // subghz_remote_writer_view_free(app->subghz_remote_writer_view); + + // // Chip detect view + // view_dispatcher_remove_view(app->view_dispatcher, SubRemViewChipDetect); + // subghz_remote_chip_detect_view_free(app->subghz_remote_chip_detect_view); + + // // View dispatcher + // view_dispatcher_free(app->view_dispatcher); + // scene_manager_free(app->scene_manager); + + // Notifications + furi_record_close(RECORD_NOTIFICATION); + app->notifications = NULL; + + // Close records + furi_record_close(RECORD_GUI); + + // Path strings + furi_string_free(app->file_path); + + // Disable 5v power + // if(furi_hal_power_is_otg_enabled()) { + // furi_hal_power_disable_otg(); + // } + + free(app); +} + +int32_t subghz_remote_app(void* p) { + UNUSED(p); + SubGhzRemoteApp* subghz_remote_app = subghz_remote_app_alloc(); + + furi_string_set(subghz_remote_app->file_path, SUBREM_APP_FOLDER); + + view_dispatcher_run(subghz_remote_app->view_dispatcher); + + subghz_remote_app_free(subghz_remote_app); + + return 0; +} diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c new file mode 100644 index 0000000000..43bdd73f31 --- /dev/null +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -0,0 +1,28 @@ +#include "subghz_remote_app_i.h" +#include +#include + +#define TAG "SubGhzRemote" + +bool subrem_load_from_file(SubGhzRemoteApp* app) { + furi_assert(app); + + FuriString* file_path = furi_string_alloc(); + + DialogsFileBrowserOptions browser_options; + dialog_file_browser_set_basic_options(&browser_options, SUBREM_APP_EXTENSION, &I_sub1_10px); + browser_options.base_path = SUBREM_APP_FOLDER; + + // Input events and views are managed by file_select + bool res = + dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options); + + if(res) { + // res = subghz_key_load(app, furi_string_get_cstr(app->file_path), true); + res = false; + } + + furi_string_free(file_path); + + return res; +} diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h new file mode 100644 index 0000000000..bc8c61cdd9 --- /dev/null +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -0,0 +1,53 @@ +#pragma once + +#include "helpers/subrem_types.h" + +#include "views/transmitter.h" + +#include "scenes/subrem_scene.h" + +#include // TODO: +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// #include "views/subghz_remote_view_programmer.h" +// #include "views/subghz_remote_view_reader.h" +// #include "views/subghz_remote_view_writer.h" +// #include "views/subghz_remote_view_chip_detect.h" + +#define SUBREM_APP_EXTENSION ".txt" +#define SUBREM_APP_FOLDER "/ext/subghz_remote" +#define SUBGHZ_REMOTE_MAX_LEN_NAME 64 + +typedef struct { + Gui* gui; + ViewDispatcher* view_dispatcher; + SceneManager* scene_manager; + NotificationApp* notifications; + DialogsApp* dialogs; + Popup* popup; + Submenu* submenu; + Widget* widget; + TextInput* text_input; + FuriString* file_path; + char file_name_tmp[SUBGHZ_REMOTE_MAX_LEN_NAME]; + + SubRemViewRemote* subrem_remote_view; + + // AvrIspProgrammerView* subghz_remote_programmer_view; + // AvrIspReaderView* subghz_remote_reader_view; + // AvrIspWriterView* subghz_remote_writer_view; + // AvrIspChipDetectView* subghz_remote_chip_detect_view; + + // AvrIspError error; +} SubGhzRemoteApp; + +bool subrem_load_from_file(SubGhzRemoteApp* app); \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/transmitter.c b/applications/external/subghz_remote_new/views/transmitter.c new file mode 100644 index 0000000000..a3589339d8 --- /dev/null +++ b/applications/external/subghz_remote_new/views/transmitter.c @@ -0,0 +1,277 @@ +#include "transmitter.h" +#include "../subghz_remote_app_i.h" + +#include +#include + +#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 16 +struct SubRemViewRemote { + View* view; + SubRemViewRemoteCallback callback; + void* context; +}; +// FIXME: drop +// static char* char_to_str(char* str, int i) { +// char* converted = malloc(sizeof(char) * i + 1); +// memcpy(converted, str, i); + +// converted[i] = '\0'; + +// return converted; +// } + +// TODO: model + +typedef struct { + // FuriString* up_label; + // FuriString* down_label; + // FuriString* left_label; + // FuriString* right_label; + // FuriString* ok_label; + + char* up_label; + char* down_label; + char* left_label; + char* right_label; + char* ok_label; + + uint8_t pressed_btn; + // bool show_button; + // FuriString* temp_button_id; + // bool draw_temp_button; +} SubRemViewRemoteModel; + +void subrem_view_remote_set_callback( + SubRemViewRemote* subrem_view_remote, + SubRemViewRemoteCallback callback, + void* context) { + furi_assert(subrem_view_remote); + + subrem_view_remote->callback = callback; + subrem_view_remote->context = context; +} + +void subrem_view_remote_add_data_to_show( + SubRemViewRemote* subrem_view_remote, + const char* up_label, + const char* down_label, + const char* left_label, + const char* right_label, + const char* ok_label) { + furi_assert(subrem_view_remote); + + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { + strncpy(model->up_label, up_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->down_label, down_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->left_label, left_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->right_label, right_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->ok_label, ok_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + + // model->up_label = char_to_str((char*)up_label, 16); + // model->down_label = char_to_str((char*)down_label, 16); + // model->left_label = char_to_str((char*)left_label, 16); + // model->right_label = char_to_str((char*)right_label, 16); + // model->ok_label = char_to_str((char*)ok_label, 16); + + // furi_string_set(model->up_label, up_label); + // furi_string_set(model->down_label, down_label); + // furi_string_set(model->left_label, left_label); + // furi_string_set(model->right_label, right_label); + // furi_string_set(model->ok_label, ok_label); + }, + true); +} + +void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { + canvas_clear(canvas); + canvas_set_color(canvas, ColorBlack); + + //map found, draw all the things + canvas_clear(canvas); + + //canvas_set_font(canvas, FontPrimary); + //canvas_draw_str(canvas, 0, 10, "U: "); + //canvas_draw_str(canvas, 0, 20, "L: "); + //canvas_draw_str(canvas, 0, 30, "R: "); + //canvas_draw_str(canvas, 0, 40, "D: "); + //canvas_draw_str(canvas, 0, 50, "Ok: "); + + //PNGs are located in assets/icons/SubGHzRemote before compilation + + //Icons for Labels + //canvas_draw_icon(canvas, 0, 0, &I_SubGHzRemote_LeftAlignedButtons_9x64); + canvas_draw_icon(canvas, 1, 5, &I_ButtonUp_7x4); + canvas_draw_icon(canvas, 1, 15, &I_ButtonDown_7x4); + canvas_draw_icon(canvas, 2, 23, &I_ButtonLeft_4x7); + canvas_draw_icon(canvas, 2, 33, &I_ButtonRight_4x7); + canvas_draw_icon(canvas, 0, 42, &I_Ok_btn_9x9); + canvas_draw_icon(canvas, 0, 53, &I_back_10px); + + //Labels + canvas_set_font(canvas, FontSecondary); + canvas_draw_str(canvas, 10, 10, model->up_label); + canvas_draw_str(canvas, 10, 20, model->down_label); + canvas_draw_str(canvas, 10, 30, model->left_label); + canvas_draw_str(canvas, 10, 40, model->right_label); + canvas_draw_str(canvas, 10, 50, model->ok_label); + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + + canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Hold=Exit."); + + //Status text and indicator + // canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, app->send_status); + + canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); + switch(model->pressed_btn) { + case 0: + break; + case 1: + canvas_draw_icon(canvas, 116, 17, &I_Pin_arrow_up_7x9); + break; + case 2: + canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180); + break; + case 3: + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); + break; + case 4: + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); + break; + case 5: + canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7); + break; + } + + //Repeat indicator + //canvas_draw_str_aligned(canvas, 125, 40, AlignRight, AlignBottom, "Repeat:"); + //canvas_draw_icon(canvas, 115, 39, &I_SubGHzRemote_Repeat_12x14); + //canvas_draw_str_aligned(canvas, 125, 62, AlignRight, AlignBottom, int_to_char(app->repeat)); +} + +bool subrem_view_remote_input(InputEvent* event, void* context) { + furi_assert(context); + SubRemViewRemote* subrem_view_remote = context; + + if(event->key == InputKeyBack && event->type == InputTypeLong) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { + strcpy(model->up_label, "N/A"); + strcpy(model->down_label, "N/A"); + strcpy(model->left_label, "N/A"); + strcpy(model->right_label, "N/A"); + strcpy(model->ok_label, "N/A"); + + // furi_string_reset(model->up_label); + // furi_string_reset(model->down_label); + // furi_string_reset(model->left_label); + // furi_string_reset(model->right_label); + // furi_string_reset(model->ok_label); + }, + false); + return false; + } else if(event->key == InputKeyUp) { + if(event->type == InputTypePress) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = 1; }, + true); + return true; + } else if(event->type == InputTypeRelease) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = 0; }, + true); + return true; + } + } + return true; +} + +void subrem_view_remote_enter(void* context) { + furi_assert(context); +} + +void subrem_view_remote_exit(void* context) { + furi_assert(context); +} + +SubRemViewRemote* subrem_view_remote_alloc() { + SubRemViewRemote* subrem_view_remote = malloc(sizeof(SubRemViewRemote)); + + // View allocation and configuration + subrem_view_remote->view = view_alloc(); + view_allocate_model( + subrem_view_remote->view, ViewModelTypeLocking, sizeof(SubRemViewRemoteModel)); + view_set_context(subrem_view_remote->view, subrem_view_remote); + view_set_draw_callback(subrem_view_remote->view, (ViewDrawCallback)subrem_view_remote_draw); + view_set_input_callback(subrem_view_remote->view, subrem_view_remote_input); + view_set_enter_callback(subrem_view_remote->view, subrem_view_remote_enter); + view_set_exit_callback(subrem_view_remote->view, subrem_view_remote_exit); + + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { + model->up_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + model->down_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + model->left_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + model->right_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + model->ok_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + + strcpy(model->up_label, "N/A"); + strcpy(model->down_label, "N/A"); + strcpy(model->left_label, "N/A"); + strcpy(model->right_label, "N/A"); + strcpy(model->ok_label, "N/A"); + + // model->up_label = furi_string_alloc(); + // model->down_label = furi_string_alloc(); + // model->left_label = furi_string_alloc(); + // model->right_label = furi_string_alloc(); + // model->ok_label = furi_string_alloc(); + + model->pressed_btn = 0; + }, + true); + return subrem_view_remote; +} + +void subrem_view_remote_free(SubRemViewRemote* subghz_remote) { + furi_assert(subghz_remote); + + with_view_model( + subghz_remote->view, + SubRemViewRemoteModel * model, + { + free(model->up_label); + free(model->down_label); + free(model->left_label); + free(model->right_label); + free(model->ok_label); + + // furi_string_free(model->up_label); + // furi_string_free(model->down_label); + // furi_string_free(model->left_label); + // furi_string_free(model->right_label); + // furi_string_free(model->ok_label); + }, + true); + view_free(subghz_remote->view); + free(subghz_remote); +} + +View* subrem_view_remote_get_view(SubRemViewRemote* subrem_view_remote) { + furi_assert(subrem_view_remote); + return subrem_view_remote->view; +} \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/transmitter.h b/applications/external/subghz_remote_new/views/transmitter.h new file mode 100644 index 0000000000..a324d09ece --- /dev/null +++ b/applications/external/subghz_remote_new/views/transmitter.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include "../helpers/subrem_custom_event.h" + +typedef struct SubRemViewRemote SubRemViewRemote; + +typedef void (*SubRemViewRemoteCallback)(SubRemCustomEvent event, void* context); + +void subrem_view_remote_set_callback( + SubRemViewRemote* subrem_view_remote, + SubRemViewRemoteCallback callback, + void* context); + +SubRemViewRemote* subrem_view_remote_alloc(); + +void subrem_view_remote_free(SubRemViewRemote* subrem_view_remote); + +View* subrem_view_remote_get_view(SubRemViewRemote* subrem_view_remote); + +void subrem_view_remote_add_data_to_show( + SubRemViewRemote* subrem_view_remote, + const char* up_label, + const char* down_label, + const char* left_label, + const char* right_label, + const char* ok_label); \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/transmitter_old.txt b/applications/external/subghz_remote_new/views/transmitter_old.txt new file mode 100644 index 0000000000..ea2dc2f627 --- /dev/null +++ b/applications/external/subghz_remote_new/views/transmitter_old.txt @@ -0,0 +1,317 @@ +#include "transmitter.h" +#include "../subghz_remote_app_i.h" + +#include +#include + +#include + +struct SubGhzRemoteViewRemote { + View* view; + SubGhzRemoteViewRemoteCallback callback; + void* context; +}; + +typedef struct { + FuriString* frequency_str; + FuriString* preset_str; + FuriString* key_str; + // bool show_button; + // FuriString* temp_button_id; + // bool draw_temp_button; +} SubGhzRemoteViewRemoteModel; + +void subghz_view_transmitter_set_callback( + SubGhzRemoteViewRemote* subghz_transmitter, + SubGhzRemoteViewRemoteCallback callback, + void* context) { + furi_assert(subghz_transmitter); + + subghz_transmitter->callback = callback; + subghz_transmitter->context = context; +} + +void subghz_view_transmitter_add_data_to_show( + SubGhzRemoteViewRemote* subghz_transmitter, + const char* key_str, + const char* frequency_str, + const char* preset_str, + bool show_button) { + furi_assert(subghz_transmitter); + with_view_model( + subghz_transmitter->view, + SubGhzRemoteViewRemoteModel * model, + { + furi_string_set(model->key_str, key_str); + furi_string_set(model->frequency_str, frequency_str); + furi_string_set(model->preset_str, preset_str); + model->show_button = show_button; + }, + true); +} + +static void subghz_view_transmitter_button_right(Canvas* canvas, const char* str) { + const uint8_t button_height = 12; + const uint8_t vertical_offset = 3; + const uint8_t horizontal_offset = 1; + const uint8_t string_width = canvas_string_width(canvas, str); + const Icon* icon = &I_ButtonCenter_7x7; + const uint8_t icon_offset = 3; + const uint8_t icon_width_with_offset = icon_get_width(icon) + icon_offset; + const uint8_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset; + + const uint8_t x = (canvas_width(canvas) - button_width) / 2 + 40; + const uint8_t y = canvas_height(canvas); + + canvas_draw_box(canvas, x, y - button_height, button_width, button_height); + + canvas_draw_line(canvas, x - 1, y, x - 1, y - button_height + 0); + canvas_draw_line(canvas, x - 2, y, x - 2, y - button_height + 1); + canvas_draw_line(canvas, x - 3, y, x - 3, y - button_height + 2); + + canvas_draw_line(canvas, x + button_width + 0, y, x + button_width + 0, y - button_height + 0); + canvas_draw_line(canvas, x + button_width + 1, y, x + button_width + 1, y - button_height + 1); + canvas_draw_line(canvas, x + button_width + 2, y, x + button_width + 2, y - button_height + 2); + + canvas_invert_color(canvas); + canvas_draw_icon( + canvas, + x + horizontal_offset, + y - button_height + vertical_offset - 1, + &I_ButtonCenter_7x7); + canvas_draw_str( + canvas, x + horizontal_offset + icon_width_with_offset, y - vertical_offset, str); + canvas_invert_color(canvas); +} + +void subghz_view_transmitter_draw(Canvas* canvas, SubGhzRemoteViewRemoteModel* model) { + canvas_clear(canvas); + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontSecondary); + elements_multiline_text_aligned( + canvas, 0, 0, AlignLeft, AlignTop, furi_string_get_cstr(model->key_str)); + canvas_draw_str(canvas, 78, 7, furi_string_get_cstr(model->frequency_str)); + canvas_draw_str(canvas, 113, 7, furi_string_get_cstr(model->preset_str)); + + // if(model->draw_temp_button) { + // canvas_set_font(canvas, FontBatteryPercent); + // canvas_draw_str(canvas, 117, 40, furi_string_get_cstr(model->temp_button_id)); + // canvas_set_font(canvas, FontSecondary); + // } + + // if(model->show_button) { + // canvas_draw_str(canvas, 58, 62, furi_hal_subghz_get_radio_type() ? "R: Ext" : "R: Int"); + // subghz_view_transmitter_button_right(canvas, "Send"); + // } +} + +bool subghz_view_transmitter_input(InputEvent* event, void* context) { + furi_assert(context); + SubGhzRemoteViewRemote* subghz_transmitter = context; + bool can_be_sent = false; + + if(event->key == InputKeyBack && event->type == InputTypeShort) { + with_view_model( + subghz_transmitter->view, + SubGhzRemoteViewRemoteModel * model, + { + furi_string_reset(model->frequency_str); + furi_string_reset(model->preset_str); + furi_string_reset(model->key_str); + furi_string_reset(model->temp_button_id); + model->show_button = false; + model->draw_temp_button = false; + }, + false); + return false; + } + + with_view_model( + subghz_transmitter->view, + SubGhzRemoteViewRemoteModel * model, + { + if(model->show_button) { + can_be_sent = true; + } + }, + true); + + if(can_be_sent && event->key == InputKeyOk && event->type == InputTypePress) { + subghz_custom_btn_set(0); + with_view_model( + subghz_transmitter->view, + SubGhzRemoteViewRemoteModel * model, + { + furi_string_reset(model->temp_button_id); + model->draw_temp_button = false; + }, + true); + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); + return true; + } else if(can_be_sent && event->key == InputKeyOk && event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; + } + + // Temp Buttons (UP) + if(can_be_sent && event->key == InputKeyUp && event->type == InputTypePress) { + subghz_custom_btn_set(1); + with_view_model( + subghz_transmitter->view, + SubGhzRemoteViewRemoteModel * model, + { + furi_string_reset(model->temp_button_id); + if(subghz_custom_btn_get_original() != 0) { + if(subghz_custom_btn_get() == 1) { + furi_string_printf( + model->temp_button_id, "%01X", subghz_custom_btn_get_original()); + model->draw_temp_button = true; + } + } + }, + true); + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); + return true; + } else if(can_be_sent && event->key == InputKeyUp && event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; + } + // Down + if(can_be_sent && event->key == InputKeyDown && event->type == InputTypePress) { + subghz_custom_btn_set(2); + with_view_model( + subghz_transmitter->view, + SubGhzRemoteViewRemoteModel * model, + { + furi_string_reset(model->temp_button_id); + if(subghz_custom_btn_get_original() != 0) { + if(subghz_custom_btn_get() == 2) { + furi_string_printf( + model->temp_button_id, "%01X", subghz_custom_btn_get_original()); + model->draw_temp_button = true; + } + } + }, + true); + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); + return true; + } else if(can_be_sent && event->key == InputKeyDown && event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; + } + // Left + if(can_be_sent && event->key == InputKeyLeft && event->type == InputTypePress) { + subghz_custom_btn_set(3); + with_view_model( + subghz_transmitter->view, + SubGhzRemoteViewRemoteModel * model, + { + furi_string_reset(model->temp_button_id); + if(subghz_custom_btn_get_original() != 0) { + if(subghz_custom_btn_get() == 3) { + furi_string_printf( + model->temp_button_id, "%01X", subghz_custom_btn_get_original()); + model->draw_temp_button = true; + } + } + }, + true); + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); + return true; + } else if(can_be_sent && event->key == InputKeyLeft && event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; + } + // Right + if(can_be_sent && event->key == InputKeyRight && event->type == InputTypePress) { + subghz_custom_btn_set(4); + with_view_model( + subghz_transmitter->view, + SubGhzRemoteViewRemoteModel * model, + { + furi_string_reset(model->temp_button_id); + if(subghz_custom_btn_get_original() != 0) { + if(subghz_custom_btn_get() == 4) { + furi_string_printf( + model->temp_button_id, "%01X", subghz_custom_btn_get_original()); + model->draw_temp_button = true; + } + } + }, + true); + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); + return true; + } else if(can_be_sent && event->key == InputKeyRight && event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; + } + + return true; +} + +void subghz_view_transmitter_enter(void* context) { + furi_assert(context); +} + +void subghz_view_transmitter_exit(void* context) { + furi_assert(context); +} + +SubGhzRemoteViewRemote* subghz_view_transmitter_alloc() { + SubGhzRemoteViewRemote* subghz_transmitter = malloc(sizeof(SubGhzRemoteViewRemote)); + + // View allocation and configuration + subghz_transmitter->view = view_alloc(); + view_allocate_model( + subghz_transmitter->view, ViewModelTypeLocking, sizeof(SubGhzRemoteViewRemoteModel)); + view_set_context(subghz_transmitter->view, subghz_transmitter); + view_set_draw_callback( + subghz_transmitter->view, (ViewDrawCallback)subghz_view_transmitter_draw); + view_set_input_callback(subghz_transmitter->view, subghz_view_transmitter_input); + view_set_enter_callback(subghz_transmitter->view, subghz_view_transmitter_enter); + view_set_exit_callback(subghz_transmitter->view, subghz_view_transmitter_exit); + + with_view_model( + subghz_transmitter->view, + SubGhzRemoteViewRemoteModel * model, + { + model->frequency_str = furi_string_alloc(); + model->preset_str = furi_string_alloc(); + model->key_str = furi_string_alloc(); + model->temp_button_id = furi_string_alloc(); + }, + true); + return subghz_transmitter; +} + +void subghz_view_transmitter_free(SubGhzRemoteViewRemote* subghz_transmitter) { + furi_assert(subghz_transmitter); + + with_view_model( + subghz_transmitter->view, + SubGhzRemoteViewRemoteModel * model, + { + furi_string_free(model->frequency_str); + furi_string_free(model->preset_str); + furi_string_free(model->key_str); + furi_string_free(model->temp_button_id); + }, + true); + view_free(subghz_transmitter->view); + free(subghz_transmitter); +} + +View* subghz_view_transmitter_get_view(SubGhzRemoteViewRemote* subghz_transmitter) { + furi_assert(subghz_transmitter); + return subghz_transmitter->view; +} From 8c3fe81edd8e1f2a138f02f927ef301add559ce5 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sun, 14 May 2023 23:23:18 +0300 Subject: [PATCH 02/92] Preset logic --- .../subghz_remote_new/helpers/subrem_types.h | 12 + .../subghz_remote_new/subghz_remote_app.c | 13 ++ .../subghz_remote_new/subghz_remote_app_i.c | 215 +++++++++++++++++- .../subghz_remote_new/subghz_remote_app_i.h | 29 +++ 4 files changed, 268 insertions(+), 1 deletion(-) diff --git a/applications/external/subghz_remote_new/helpers/subrem_types.h b/applications/external/subghz_remote_new/helpers/subrem_types.h index ffb2f8044e..56687977fb 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_types.h +++ b/applications/external/subghz_remote_new/helpers/subrem_types.h @@ -29,6 +29,18 @@ typedef enum { SubRemViewIDRemote, //SubRemViewChipDetect, } SubRemViewID; + +typedef enum { + // Loadin State + SubRemSubKeyTypeNoData = 0, + SubRemSubKeyTypeHaveFileName, + + // Key Type + SubRemSubKeyTypeStaticKey = 100, + SubRemSubKeyTypeDynamicKey, + SubRemSubKeyTypeRawKey, +} SubRemSubKeyType; + /* typedef enum { SubRemErrorNoError, diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_new/subghz_remote_app.c index d25e65ce71..35775c9da4 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app.c +++ b/applications/external/subghz_remote_new/subghz_remote_app.c @@ -102,6 +102,13 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { SubRemViewChipDetect, subghz_remote_chip_detect_view_get_view(app->subghz_remote_chip_detect_view)); */ + for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { + app->subs_preset[i] = subrem_sub_file_preset_alloc(); + } + + app->setting = subghz_setting_alloc(); + subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user")); + scene_manager_next_scene(app->scene_manager, SubRemSceneStart); return app; @@ -133,6 +140,12 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDRemote); subrem_view_remote_free(app->subrem_remote_view); + subghz_setting_free(app->setting); + + for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { + subrem_sub_file_preset_free(app->subs_preset[i]); + } + // // Reader view // view_dispatcher_remove_view(app->view_dispatcher, SubRemViewReader); // subghz_remote_reader_view_free(app->subghz_remote_reader_view); diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index 43bdd73f31..bc874946d6 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -2,8 +2,220 @@ #include #include +#include +#include + #define TAG "SubGhzRemote" +static const char* map_file_labels[SUBREM_MAX_SUB_KEY_COUNT][2] = { + {"OK", "OKLABEL"}, + {"UP", "ULABEL"}, + {"DOWN", "DLABEL"}, + {"LEFT", "LLABEL"}, + {"RIGHT", "RLABEL"}, +}; + +bool subrem_set_preset_data(SubGhzSetting* setting, FreqPreset* freq_preset, const char* preset) { + const char* preset_name = ""; + if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) { + preset_name = "AM270"; + } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) { + preset_name = "AM650"; + } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) { + preset_name = "FM238"; + } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) { + preset_name = "FM476"; + } else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) { + // preset_name = "CUSTOM"; + return false; + } else { + FURI_LOG_E(TAG, "Unknown preset"); + return false; + } + size_t preset_index = subghz_setting_get_inx_preset_by_name(setting, preset_name); + freq_preset->data = subghz_setting_get_preset_data(setting, preset_index); + return true; +} + +SubRemSubFilePreset* subrem_sub_file_preset_alloc() { + SubRemSubFilePreset* sub_preset = malloc(sizeof(SubRemSubFilePreset)); + + sub_preset->fff_data = flipper_format_string_alloc(); + sub_preset->file_path = furi_string_alloc(); + sub_preset->label = furi_string_alloc_set_str("N/A"); + sub_preset->type = SubRemSubKeyTypeNoData; + + return sub_preset; +} + +void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { + furi_assert(sub_preset); + + furi_string_free(sub_preset->label); + furi_string_free(sub_preset->file_path); + flipper_format_free(sub_preset->fff_data); + + free(sub_preset); +} + +static bool subrem_sub_file_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { + furi_assert(app); + bool ret = false; + + for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { + if(!flipper_format_read_string( + fff_data_file, map_file_labels[i][0], app->subs_preset[i]->file_path)) { + FURI_LOG_W(TAG, "No file patch for %s", map_file_labels[i][0]); + app->subs_preset[i]->type = SubRemSubKeyTypeNoData; + //continue; + } else if(!flipper_format_rewind(fff_data_file)) { + // Rewind error + //continue; + } else if(!flipper_format_read_string( + fff_data_file, map_file_labels[i][1], app->subs_preset[i]->label)) { + FURI_LOG_W(TAG, "No Label for %s", map_file_labels[i][0]); + furi_string_set_str(app->subs_preset[i]->label, "N/A"); + } else { + FURI_LOG_I( + TAG, + // "Loaded %s key \r\nLabel %s file %s", + "Loaded %s key: %s %s", + map_file_labels[i][0], + furi_string_get_cstr(app->subs_preset[i]->label), + furi_string_get_cstr(app->subs_preset[i]->file_path)); + app->subs_preset[i]->type = SubRemSubKeyTypeHaveFileName; // TODO + ret = true; + } + flipper_format_rewind(fff_data_file); + } + return ret; +} + +static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { + furi_assert(app); + FuriString* temp_str = furi_string_alloc(); + uint32_t temp_data32; + bool ret = false; + SubRemSubFilePreset* sub_preset; + + // TODO: + // const SubGhzProtocolRegistry* protocol_registry_items = + // subghz_environment_get_protocol_registry(app->environment); + + for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { + sub_preset = app->subs_preset[i]; + if(sub_preset->type == SubRemSubKeyTypeNoData) { + continue; + } + do { + if(!flipper_format_file_open_existing( + fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { + FURI_LOG_E( + TAG, + "Error open file %s", + furi_string_get_cstr(sub_preset->file_path)); // TODO: warning + break; + } + + if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) { + FURI_LOG_E(TAG, "Missing or incorrect header"); + break; + } + + if(((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) || + (!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) && + temp_data32 == SUBGHZ_KEY_FILE_VERSION) { + } else { + FURI_LOG_E(TAG, "Type or version mismatch"); + break; + } + + //Load frequency + if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { + FURI_LOG_W(TAG, "Cannot read frequency. Defaulting to 433.92 MHz"); + sub_preset->freq_preset.frequency = subghz_setting_get_default_frequency( + app->setting); // TODO: Get default from settings + } else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { + FURI_LOG_E(TAG, "This frequency can only be used for RX"); + break; + } else { + sub_preset->freq_preset.frequency = temp_data32; + } + + //Load preset + if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { + FURI_LOG_E(TAG, "Missing Preset"); + break; + } + + if(!subrem_set_preset_data( + app->setting, &sub_preset->freq_preset, furi_string_get_cstr(temp_str))) { + FURI_LOG_E(TAG, "Cannot load preset."); + break; + } + + //Load protocol + if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { + FURI_LOG_E(TAG, "Missing Protocol"); + break; + } + + FlipperFormat* fff_data = sub_preset->fff_data; + if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) { + //if RAW + subghz_protocol_raw_gen_fff_data( + fff_data, furi_string_get_cstr(sub_preset->file_path)); + sub_preset->type = SubRemSubKeyTypeRawKey; + } else { + stream_copy_full( + flipper_format_get_raw_stream(fff_data_file), + flipper_format_get_raw_stream(fff_data)); + } + + // subghz_protocol_registry_get_by_name( + // protocol_registry_items, furi_string_get_cstr(temp_str)); // TODO: check dynamic and protocol found + + } while(false); + + flipper_format_file_close(fff_data_file); + } + furi_string_free(temp_str); + + ret = false; // TODO: + return ret; +} + +bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { + furi_assert(app); + furi_assert(file_path); + // TODO: drop furi log + FURI_LOG_I(TAG, "Load Map File Start"); // drop + Storage* storage = furi_record_open(RECORD_STORAGE); + FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); + bool ret = false; + FURI_LOG_I(TAG, "Open Map File.."); // drop + if(!flipper_format_file_open_existing(fff_data_file, file_path)) { + FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); + } else { + if(!subrem_sub_file_preset_load(app, fff_data_file)) { + // TODO: error popup or return error type + FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); + } else if(!(flipper_format_file_close(fff_data_file) && + subrem_sub_presets_check(app, fff_data_file))) { + ret = true; + } + } + + flipper_format_file_close(fff_data_file); + flipper_format_free(fff_data_file); + + furi_record_close(RECORD_STORAGE); + + FURI_LOG_I(TAG, "Load Map File Done"); // drop + ret = false; // TODO + return ret; +} + bool subrem_load_from_file(SubGhzRemoteApp* app) { furi_assert(app); @@ -18,7 +230,8 @@ bool subrem_load_from_file(SubGhzRemoteApp* app) { dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options); if(res) { - // res = subghz_key_load(app, furi_string_get_cstr(app->file_path), true); + res = subrem_map_file_load(app, furi_string_get_cstr(app->file_path)); + // FIXME res = subghz_key_load(app, furi_string_get_cstr(app->file_path), true); res = false; } diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index bc8c61cdd9..e01ba939ea 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -18,6 +18,12 @@ #include #include +#include +#include +#include + +#include // FIXME: + // #include "views/subghz_remote_view_programmer.h" // #include "views/subghz_remote_view_reader.h" // #include "views/subghz_remote_view_writer.h" @@ -26,6 +32,25 @@ #define SUBREM_APP_EXTENSION ".txt" #define SUBREM_APP_FOLDER "/ext/subghz_remote" #define SUBGHZ_REMOTE_MAX_LEN_NAME 64 +#define SUBREM_MAX_SUB_KEY_COUNT (5U) + +typedef struct { + uint32_t frequency; + uint8_t* data; +} FreqPreset; + +// Sub File preset +typedef struct { + FlipperFormat* fff_data; + FreqPreset freq_preset; + FuriString* file_path; + FuriString* label; + SubRemSubKeyType type; +} SubRemSubFilePreset; + +SubRemSubFilePreset* subrem_sub_file_preset_alloc(); + +void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset); typedef struct { Gui* gui; @@ -42,6 +67,10 @@ typedef struct { SubRemViewRemote* subrem_remote_view; + SubRemSubFilePreset* subs_preset[SUBREM_MAX_SUB_KEY_COUNT]; + + SubGhzSetting* setting; + // AvrIspProgrammerView* subghz_remote_programmer_view; // AvrIspReaderView* subghz_remote_reader_view; // AvrIspWriterView* subghz_remote_writer_view; From 3f33fe8cb0864604e758bec767cad51ff04efa1a Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Mon, 15 May 2023 15:05:04 +0300 Subject: [PATCH 03/92] add TX --- .../helpers/subrem_custom_event.h | 7 + .../scenes/subrem_scene_openmapfile.c | 1 + .../scenes/subrem_scene_remote.c | 26 +++- .../subghz_remote_new/subghz_remote_app.c | 37 +++++ .../subghz_remote_new/subghz_remote_app_i.c | 144 ++++++++++++++++-- .../subghz_remote_new/subghz_remote_app_i.h | 9 +- .../subghz_remote_new/views/transmitter.c | 4 + 7 files changed, 206 insertions(+), 22 deletions(-) diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h index d1559a7960..0e0ab94ef4 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h +++ b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h @@ -11,6 +11,13 @@ typedef enum { //SubRemCustomEvent SubRemCustomEventViewRemoteBack = 100, + SubRemCustomEventViewRemoteStartUP, + SubRemCustomEventViewRemoteStartDOWN, + SubRemCustomEventViewRemoteStartLEFT, + SubRemCustomEventViewRemoteStartRIGHT, + SubRemCustomEventViewRemoteStartOK, + SubRemCustomEventViewRemoteStop, + // SubRemCustomEventSceneDeleteSuccess = 100, // SubRemCustomEventSceneDelete, // SubRemCustomEventSceneDeleteRAW, diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c index 8e651a5347..67ccca1c39 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c @@ -10,6 +10,7 @@ void subrem_scene_openmapfile_on_enter(void* context) { // } else { // scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSavedMenu); // } + scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); } else { scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SubRemSceneStart); } diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c index 787a717608..58e253d1ce 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c @@ -21,11 +21,18 @@ bool subrem_scene_remote_update_data_show(void* context) { subrem_view_remote_add_data_to_show( //app->subrem_remote_view, "N/A", "N/A", "N/A", "N/A", "N/A"); app->subrem_remote_view, - "UP", - "DOWN", - "LEFT", - "RIGHT", - "OK"); + // "UP", + // "DOWN", + // "LEFT", + // "RIGHT", + // "OK"); + + furi_string_get_cstr(app->subs_preset[0]->label), + furi_string_get_cstr(app->subs_preset[1]->label), + furi_string_get_cstr(app->subs_preset[2]->label), + furi_string_get_cstr(app->subs_preset[3]->label), + furi_string_get_cstr(app->subs_preset[4]->label)); + // SubGhzProtocolDecoderBase* decoder = subghz_txrx_get_decoder(app->txrx); // if(decoder) { @@ -105,7 +112,16 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { scene_manager_search_and_switch_to_previous_scene( app->scene_manager, SubRemSceneStart); return true; + } else if(event.event == SubRemCustomEventViewRemoteStartUP) { + if(subghz_tx_start_sub(app, app->subs_preset[0])) { + notification_message(app->notifications, &sequence_blink_start_magenta); + } + } else if(event.event == SubRemCustomEventViewRemoteStop) { + subghz_tx_stop_sub(app, app->subs_preset[0]); + notification_message(app->notifications, &sequence_blink_stop); } + // notification_message(app->notification, &sequence_blink_stop); + // else if(event.event == SubGhzCustomEventViewTransmitterError) { // furi_string_set(app->error_str, "Protocol not\nfound!"); // scene_manager_next_scene(app->scene_manager, SubGhzSceneShowErrorSub); diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_new/subghz_remote_app.c index 35775c9da4..1bfa3a1b3a 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app.c +++ b/applications/external/subghz_remote_new/subghz_remote_app.c @@ -1,5 +1,7 @@ #include "subghz_remote_app_i.h" +#include + static bool subghz_remote_app_custom_event_callback(void* context, uint32_t event) { furi_assert(context); SubGhzRemoteApp* app = context; @@ -21,6 +23,17 @@ static void subghz_remote_app_tick_event_callback(void* context) { SubGhzRemoteApp* subghz_remote_app_alloc() { SubGhzRemoteApp* app = malloc(sizeof(SubGhzRemoteApp)); + // Enable power for External CC1101 if it is connected + furi_hal_subghz_enable_ext_power(); + // Auto switch to internal radio if external radio is not available + furi_delay_ms(15); + if(!furi_hal_subghz_check_radio()) { + furi_hal_subghz_select_radio_type(SubGhzRadioInternal); + furi_hal_subghz_init_radio_type(SubGhzRadioInternal); + } + + furi_hal_power_suppress_charge_enter(); + // // Enable 5v power, multiple attempts to avoid issues with power chip protection false triggering // uint8_t attempts = 0; // while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { @@ -109,6 +122,21 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { app->setting = subghz_setting_alloc(); subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user")); + app->environment = subghz_environment_alloc(); + + subghz_environment_load_keystore(app->environment, EXT_PATH("subghz/assets/keeloq_mfcodes")); + subghz_environment_load_keystore( + app->environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user")); + subghz_environment_set_came_atomo_rainbow_table_file_name( + app->environment, EXT_PATH("subghz/assets/came_atomo")); + subghz_environment_set_alutech_at_4n_rainbow_table_file_name( + app->environment, EXT_PATH("subghz/assets/alutech_at_4n")); + subghz_environment_set_nice_flor_s_rainbow_table_file_name( + app->environment, EXT_PATH("subghz/assets/nice_flor_s")); + subghz_environment_set_protocol_registry(app->environment, (void*)&subghz_protocol_registry); + + app->receiver = subghz_receiver_alloc_init(app->environment); + scene_manager_next_scene(app->scene_manager, SubRemSceneStart); return app; @@ -117,6 +145,13 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { void subghz_remote_app_free(SubGhzRemoteApp* app) { furi_assert(app); + furi_hal_power_suppress_charge_exit(); + + // Disable power for External CC1101 if it was enabled and module is connected + furi_hal_subghz_disable_ext_power(); + // Reinit SPI handles for internal radio / nfc + furi_hal_subghz_init_radio_type(SubGhzRadioInternal); + // Submenu view_dispatcher_remove_view(app->view_dispatcher, SubRemViewSubmenu); submenu_free(app->submenu); @@ -140,6 +175,8 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDRemote); subrem_view_remote_free(app->subrem_remote_view); + subghz_receiver_free(app->receiver); + subghz_environment_free(app->environment); subghz_setting_free(app->setting); for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index bc874946d6..7ebad702fb 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -8,11 +8,11 @@ #define TAG "SubGhzRemote" static const char* map_file_labels[SUBREM_MAX_SUB_KEY_COUNT][2] = { - {"OK", "OKLABEL"}, {"UP", "ULABEL"}, {"DOWN", "DLABEL"}, {"LEFT", "LLABEL"}, {"RIGHT", "RLABEL"}, + {"OK", "OKLABEL"}, }; bool subrem_set_preset_data(SubGhzSetting* setting, FreqPreset* freq_preset, const char* preset) { @@ -42,7 +42,9 @@ SubRemSubFilePreset* subrem_sub_file_preset_alloc() { sub_preset->fff_data = flipper_format_string_alloc(); sub_preset->file_path = furi_string_alloc(); + sub_preset->protocaol_name = furi_string_alloc(); sub_preset->label = furi_string_alloc_set_str("N/A"); + sub_preset->type = SubRemSubKeyTypeNoData; return sub_preset; @@ -52,13 +54,35 @@ void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { furi_assert(sub_preset); furi_string_free(sub_preset->label); + furi_string_free(sub_preset->protocaol_name); furi_string_free(sub_preset->file_path); flipper_format_free(sub_preset->fff_data); free(sub_preset); } -static bool subrem_sub_file_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { +void subrem_subs_file_preset_reset(SubRemSubFilePreset* sub_preset) { + furi_assert(sub_preset); + + furi_string_set_str(sub_preset->label, "N/A"); + furi_string_reset(sub_preset->protocaol_name); + furi_string_reset(sub_preset->file_path); + + Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); + stream_clean(fff_data_stream); + + sub_preset->type = SubRemSubKeyTypeNoData; +} + +void subrem_sub_file_presets_reset(SubGhzRemoteApp* app) { + furi_assert(app); + + for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { + subrem_subs_file_preset_reset(app->subs_preset[i]); + } +} + +static bool subrem_sub_file_presets_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); bool ret = false; @@ -83,7 +107,7 @@ static bool subrem_sub_file_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff map_file_labels[i][0], furi_string_get_cstr(app->subs_preset[i]->label), furi_string_get_cstr(app->subs_preset[i]->file_path)); - app->subs_preset[i]->type = SubRemSubKeyTypeHaveFileName; // TODO + app->subs_preset[i]->type = SubRemSubKeyTypeHaveFileName; // TODO: ret = true; } flipper_format_rewind(fff_data_file); @@ -91,6 +115,67 @@ static bool subrem_sub_file_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff return ret; } +bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { + furi_assert(app); + furi_assert(sub_preset); + bool ret = false; + + FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); + + do { + flipper_format_rewind(sub_preset->fff_data); // FIXME: + + app->transmitter = subghz_transmitter_alloc_init( + app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); + + if(app->transmitter) { + if(subghz_transmitter_deserialize(app->transmitter, sub_preset->fff_data) != + SubGhzProtocolStatusOk) { + FURI_LOG_E(TAG, "Deserialize error!"); + break; + } + furi_hal_subghz_reset(); + furi_hal_subghz_idle(); + furi_hal_subghz_load_custom_preset(sub_preset->freq_preset.data); + furi_hal_gpio_init( + furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); + + furi_hal_subghz_idle(); + + furi_hal_subghz_set_frequency_and_path(sub_preset->freq_preset.frequency); + furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); + furi_hal_gpio_init( + furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); + + if(!furi_hal_subghz_tx()) { + FURI_LOG_E(TAG, "Sending not allowed"); + break; + } + + furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); + + ret = true; + } + } while(false); + + // ret = false; // TODO: + return ret; +} + +void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { + furi_assert(app); + furi_assert(sub_preset); + + //Stop TX + furi_hal_subghz_stop_async_tx(); + + subghz_transmitter_stop(app->transmitter); + subghz_transmitter_free(app->transmitter); + furi_hal_subghz_idle(); + + // TODO: need saving logic +} + static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); FuriString* temp_str = furi_string_alloc(); @@ -98,10 +183,6 @@ static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_da bool ret = false; SubRemSubFilePreset* sub_preset; - // TODO: - // const SubGhzProtocolRegistry* protocol_registry_items = - // subghz_environment_get_protocol_registry(app->environment); - for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { sub_preset = app->subs_preset[i]; if(sub_preset->type == SubRemSubKeyTypeNoData) { @@ -172,16 +253,44 @@ static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_da flipper_format_get_raw_stream(fff_data)); } - // subghz_protocol_registry_get_by_name( - // protocol_registry_items, furi_string_get_cstr(temp_str)); // TODO: check dynamic and protocol found + const SubGhzProtocolRegistry* protocol_registry_items = + subghz_environment_get_protocol_registry(app->environment); + + const SubGhzProtocol* protocol = subghz_protocol_registry_get_by_name( + protocol_registry_items, furi_string_get_cstr(temp_str)); + if(!protocol) { + FURI_LOG_E(TAG, "Protocol not found"); + break; + } else if(protocol->flag & SubGhzProtocolFlag_Send) { // FIXME: + + if(protocol->type == SubGhzProtocolTypeStatic) { + sub_preset->type = SubRemSubKeyTypeStaticKey; + } else if(protocol->type == SubGhzProtocolTypeDynamic) { + sub_preset->type = SubRemSubKeyTypeDynamicKey; + } else if(protocol->type == SubGhzProtocolTypeRAW) { + sub_preset->type = SubRemSubKeyTypeRawKey; + // } else if(protocol->type == SubGhzProtocolTypeBinRAW) { // TODO: BINRAW + } else { + FURI_LOG_E(TAG, "Unsuported Protocol"); + break; + } + + furi_string_set(sub_preset->protocaol_name, temp_str); + } // TODO: check dynamic and protocol found + + ret |= true; + + if(ret) { + FURI_LOG_I(TAG, "Protocol Loaded"); + } } while(false); flipper_format_file_close(fff_data_file); } furi_string_free(temp_str); - ret = false; // TODO: + //ret = false; // TODO: return ret; } @@ -194,14 +303,19 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); bool ret = false; FURI_LOG_I(TAG, "Open Map File.."); // drop + + subrem_sub_file_presets_reset(app); + if(!flipper_format_file_open_existing(fff_data_file, file_path)) { FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); } else { - if(!subrem_sub_file_preset_load(app, fff_data_file)) { + if(!subrem_sub_file_presets_load(app, fff_data_file)) { // TODO: error popup or return error type FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); - } else if(!(flipper_format_file_close(fff_data_file) && - subrem_sub_presets_check(app, fff_data_file))) { + } else if( + (flipper_format_file_close(fff_data_file)) && + (subrem_sub_presets_check(app, fff_data_file))) { + FURI_LOG_I(TAG, "Load Map File Seccesful"); ret = true; } } @@ -211,8 +325,7 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { furi_record_close(RECORD_STORAGE); - FURI_LOG_I(TAG, "Load Map File Done"); // drop - ret = false; // TODO + //ret = false; // TODO: return ret; } @@ -232,7 +345,6 @@ bool subrem_load_from_file(SubGhzRemoteApp* app) { if(res) { res = subrem_map_file_load(app, furi_string_get_cstr(app->file_path)); // FIXME res = subghz_key_load(app, furi_string_get_cstr(app->file_path), true); - res = false; } furi_string_free(file_path); diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index e01ba939ea..d954eca023 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -44,6 +44,7 @@ typedef struct { FlipperFormat* fff_data; FreqPreset freq_preset; FuriString* file_path; + FuriString* protocaol_name; FuriString* label; SubRemSubKeyType type; } SubRemSubFilePreset; @@ -70,6 +71,9 @@ typedef struct { SubRemSubFilePreset* subs_preset[SUBREM_MAX_SUB_KEY_COUNT]; SubGhzSetting* setting; + SubGhzEnvironment* environment; + SubGhzReceiver* receiver; + SubGhzTransmitter* transmitter; // AvrIspProgrammerView* subghz_remote_programmer_view; // AvrIspReaderView* subghz_remote_reader_view; @@ -79,4 +83,7 @@ typedef struct { // AvrIspError error; } SubGhzRemoteApp; -bool subrem_load_from_file(SubGhzRemoteApp* app); \ No newline at end of file +bool subrem_load_from_file(SubGhzRemoteApp* app); + +bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); +void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/transmitter.c b/applications/external/subghz_remote_new/views/transmitter.c index a3589339d8..6f43a14066 100644 --- a/applications/external/subghz_remote_new/views/transmitter.c +++ b/applications/external/subghz_remote_new/views/transmitter.c @@ -185,6 +185,8 @@ bool subrem_view_remote_input(InputEvent* event, void* context) { SubRemViewRemoteModel * model, { model->pressed_btn = 1; }, true); + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context); return true; } else if(event->type == InputTypeRelease) { with_view_model( @@ -192,6 +194,8 @@ bool subrem_view_remote_input(InputEvent* event, void* context) { SubRemViewRemoteModel * model, { model->pressed_btn = 0; }, true); + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStop, subrem_view_remote->context); return true; } } From cdf8daff867049d16986b1109eb814cbd9ba631a Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Mon, 15 May 2023 22:11:18 +0300 Subject: [PATCH 04/92] add tx 2 --- .../helpers/subrem_custom_event.h | 1 + .../scenes/subrem_scene_remote.c | 65 +++++++++++++++- .../subghz_remote_new/subghz_remote_app.c | 2 + .../subghz_remote_new/subghz_remote_app_i.c | 21 ++++- .../subghz_remote_new/subghz_remote_app_i.h | 13 +++- .../subghz_remote_new/views/transmitter.c | 78 +++++++++++++------ .../subghz_remote_new/views/transmitter.h | 4 +- 7 files changed, 152 insertions(+), 32 deletions(-) diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h index 0e0ab94ef4..0c999d5e50 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h +++ b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h @@ -17,6 +17,7 @@ typedef enum { SubRemCustomEventViewRemoteStartRIGHT, SubRemCustomEventViewRemoteStartOK, SubRemCustomEventViewRemoteStop, + SubRemCustomEventViewRemoteForceStop, // SubRemCustomEventSceneDeleteSuccess = 100, // SubRemCustomEventSceneDelete, diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c index 58e253d1ce..f7da910abf 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c @@ -1,6 +1,8 @@ #include "../subghz_remote_app_i.h" #include "../views/transmitter.h" +#include + // TODO: // #include // #include @@ -13,6 +15,12 @@ void subrem_scene_remote_callback(SubRemCustomEvent event, void* context) { view_dispatcher_send_custom_event(app->view_dispatcher, event); } +void subrem_scene_remote_raw_callback_end_tx(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventViewRemoteForceStop); +} + bool subrem_scene_remote_update_data_show(void* context) { SubGhzRemoteApp* app = context; //UNUSED(app); @@ -113,12 +121,65 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { app->scene_manager, SubRemSceneStart); return true; } else if(event.event == SubRemCustomEventViewRemoteStartUP) { - if(subghz_tx_start_sub(app, app->subs_preset[0])) { + if(subghz_tx_start_sub( + app, app->subs_preset[0], subrem_scene_remote_raw_callback_end_tx)) { + app->chusen_sub = 0; + subrem_view_remote_set_state(app->subrem_remote_view, 1); + notification_message(app->notifications, &sequence_blink_start_magenta); + } + return true; + } else if(event.event == SubRemCustomEventViewRemoteStartDOWN) { + if(subghz_tx_start_sub( + app, app->subs_preset[1], subrem_scene_remote_raw_callback_end_tx)) { + app->chusen_sub = 1; + subrem_view_remote_set_state(app->subrem_remote_view, 2); + notification_message(app->notifications, &sequence_blink_start_magenta); + } + return true; + } else if(event.event == SubRemCustomEventViewRemoteStartLEFT) { + if(subghz_tx_start_sub( + app, app->subs_preset[2], subrem_scene_remote_raw_callback_end_tx)) { + app->chusen_sub = 2; + subrem_view_remote_set_state(app->subrem_remote_view, 3); notification_message(app->notifications, &sequence_blink_start_magenta); } + return true; + } else if(event.event == SubRemCustomEventViewRemoteStartRIGHT) { + if(subghz_tx_start_sub( + app, app->subs_preset[3], subrem_scene_remote_raw_callback_end_tx)) { + app->chusen_sub = 3; + subrem_view_remote_set_state(app->subrem_remote_view, 4); + notification_message(app->notifications, &sequence_blink_start_magenta); + } + return true; + } else if(event.event == SubRemCustomEventViewRemoteStartOK) { + if(subghz_tx_start_sub( + app, app->subs_preset[4], subrem_scene_remote_raw_callback_end_tx)) { + app->chusen_sub = 4; + subrem_view_remote_set_state(app->subrem_remote_view, 5); + notification_message(app->notifications, &sequence_blink_start_magenta); + } + return true; + } else if(event.event == SubRemCustomEventViewRemoteForceStop) { + if(app->tx_running) { + subghz_tx_stop_sub(app); + subrem_view_remote_set_state(app->subrem_remote_view, 0); + } + notification_message(app->notifications, &sequence_blink_stop); + return true; } else if(event.event == SubRemCustomEventViewRemoteStop) { - subghz_tx_stop_sub(app, app->subs_preset[0]); + // if(app->tx_running && + // (app->subs_preset[app->chusen_sub]->type == SubRemSubKeyTypeRawKey)) { + // subghz_tx_stop_sub(app); + // subrem_view_remote_set_state(app->subrem_remote_view, 0); + // } + // notification_message(app->notifications, &sequence_blink_stop); + if(app->tx_running) { + subghz_tx_stop_sub(app); + subrem_view_remote_set_state(app->subrem_remote_view, 0); + } notification_message(app->notifications, &sequence_blink_stop); + return true; } // notification_message(app->notification, &sequence_blink_stop); diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_new/subghz_remote_app.c index 1bfa3a1b3a..17a559da85 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app.c +++ b/applications/external/subghz_remote_new/subghz_remote_app.c @@ -137,6 +137,8 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { app->receiver = subghz_receiver_alloc_init(app->environment); + app->tx_running = false; + scene_manager_next_scene(app->scene_manager, SubRemSceneStart); return app; diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index 7ebad702fb..ef22a9e6d1 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -115,7 +115,10 @@ static bool subrem_sub_file_presets_load(SubGhzRemoteApp* app, FlipperFormat* ff return ret; } -bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { +bool subghz_tx_start_sub( + SubGhzRemoteApp* app, + SubRemSubFilePreset* sub_preset, + SubGhzProtocolEncoderRAWCallbackEnd callback) { furi_assert(app); furi_assert(sub_preset); bool ret = false; @@ -152,19 +155,26 @@ bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) break; } + if(sub_preset->type == SubRemSubKeyTypeRawKey) { + subghz_protocol_raw_file_encoder_worker_set_callback_end( + (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( + app->transmitter), + callback, + app); + } + furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); ret = true; } } while(false); + app->tx_running = ret; // TODO: - // ret = false; // TODO: return ret; } -void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { +void subghz_tx_stop_sub(SubGhzRemoteApp* app) { furi_assert(app); - furi_assert(sub_preset); //Stop TX furi_hal_subghz_stop_async_tx(); @@ -173,7 +183,10 @@ void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { subghz_transmitter_free(app->transmitter); furi_hal_subghz_idle(); + // SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; + // TODO: need saving logic + app->tx_running = false; } static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index d954eca023..13f3d63c53 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -18,6 +18,8 @@ #include #include +#include + #include #include #include @@ -75,6 +77,10 @@ typedef struct { SubGhzReceiver* receiver; SubGhzTransmitter* transmitter; + bool tx_running; + + uint8_t chusen_sub; + // AvrIspProgrammerView* subghz_remote_programmer_view; // AvrIspReaderView* subghz_remote_reader_view; // AvrIspWriterView* subghz_remote_writer_view; @@ -85,5 +91,8 @@ typedef struct { bool subrem_load_from_file(SubGhzRemoteApp* app); -bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); -void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); \ No newline at end of file +bool subghz_tx_start_sub( + SubGhzRemoteApp* app, + SubRemSubFilePreset* sub_preset, + SubGhzProtocolEncoderRAWCallbackEnd callback); +void subghz_tx_stop_sub(SubGhzRemoteApp* app); \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/transmitter.c b/applications/external/subghz_remote_new/views/transmitter.c index 6f43a14066..a814880f97 100644 --- a/applications/external/subghz_remote_new/views/transmitter.c +++ b/applications/external/subghz_remote_new/views/transmitter.c @@ -85,6 +85,15 @@ void subrem_view_remote_add_data_to_show( true); } +void subrem_view_remote_set_state(SubRemViewRemote* subrem_view_remote, uint8_t state) { + furi_assert(subrem_view_remote); + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = state; }, + true); +} + void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); @@ -139,10 +148,10 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180); break; case 3: - canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); break; case 4: - canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); break; case 5: canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7); @@ -177,28 +186,51 @@ bool subrem_view_remote_input(InputEvent* event, void* context) { // furi_string_reset(model->ok_label); }, false); - return false; - } else if(event->key == InputKeyUp) { - if(event->type == InputTypePress) { - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = 1; }, - true); - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context); - return true; - } else if(event->type == InputTypeRelease) { - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = 0; }, - true); - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStop, subrem_view_remote->context); - return true; - } + return false; // TODO: check + } else if(event->key == InputKeyBack && event->type == InputTypeShort) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = 0; }, + true); + subrem_view_remote->callback( + SubRemCustomEventViewRemoteForceStop, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyBack) { + return true; } + // BACK button processing end + + if(event->key == InputKeyUp && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyDown && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartDOWN, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyLeft && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartLEFT, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyRight && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartRIGHT, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyOk && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartOK, subrem_view_remote->context); + return true; + } else if(event->type == InputTypeRelease) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = 0; }, + true); + subrem_view_remote->callback(SubRemCustomEventViewRemoteStop, subrem_view_remote->context); + return true; + } + return true; } diff --git a/applications/external/subghz_remote_new/views/transmitter.h b/applications/external/subghz_remote_new/views/transmitter.h index a324d09ece..64985ff121 100644 --- a/applications/external/subghz_remote_new/views/transmitter.h +++ b/applications/external/subghz_remote_new/views/transmitter.h @@ -24,4 +24,6 @@ void subrem_view_remote_add_data_to_show( const char* down_label, const char* left_label, const char* right_label, - const char* ok_label); \ No newline at end of file + const char* ok_label); + +void subrem_view_remote_set_state(SubRemViewRemote* subrem_view_remote, uint8_t state); \ No newline at end of file From 075dfe8109ab3de051188f43f738443b48ebfd54 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Wed, 17 May 2023 17:48:05 +0300 Subject: [PATCH 05/92] Revert "add tx 2" This reverts commit cdf8daff867049d16986b1109eb814cbd9ba631a. --- .../helpers/subrem_custom_event.h | 1 - .../scenes/subrem_scene_remote.c | 65 +--------------- .../subghz_remote_new/subghz_remote_app.c | 2 - .../subghz_remote_new/subghz_remote_app_i.c | 21 +---- .../subghz_remote_new/subghz_remote_app_i.h | 13 +--- .../subghz_remote_new/views/transmitter.c | 78 ++++++------------- .../subghz_remote_new/views/transmitter.h | 4 +- 7 files changed, 32 insertions(+), 152 deletions(-) diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h index 0c999d5e50..0e0ab94ef4 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h +++ b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h @@ -17,7 +17,6 @@ typedef enum { SubRemCustomEventViewRemoteStartRIGHT, SubRemCustomEventViewRemoteStartOK, SubRemCustomEventViewRemoteStop, - SubRemCustomEventViewRemoteForceStop, // SubRemCustomEventSceneDeleteSuccess = 100, // SubRemCustomEventSceneDelete, diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c index f7da910abf..58e253d1ce 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c @@ -1,8 +1,6 @@ #include "../subghz_remote_app_i.h" #include "../views/transmitter.h" -#include - // TODO: // #include // #include @@ -15,12 +13,6 @@ void subrem_scene_remote_callback(SubRemCustomEvent event, void* context) { view_dispatcher_send_custom_event(app->view_dispatcher, event); } -void subrem_scene_remote_raw_callback_end_tx(void* context) { - furi_assert(context); - SubGhzRemoteApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventViewRemoteForceStop); -} - bool subrem_scene_remote_update_data_show(void* context) { SubGhzRemoteApp* app = context; //UNUSED(app); @@ -121,65 +113,12 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { app->scene_manager, SubRemSceneStart); return true; } else if(event.event == SubRemCustomEventViewRemoteStartUP) { - if(subghz_tx_start_sub( - app, app->subs_preset[0], subrem_scene_remote_raw_callback_end_tx)) { - app->chusen_sub = 0; - subrem_view_remote_set_state(app->subrem_remote_view, 1); - notification_message(app->notifications, &sequence_blink_start_magenta); - } - return true; - } else if(event.event == SubRemCustomEventViewRemoteStartDOWN) { - if(subghz_tx_start_sub( - app, app->subs_preset[1], subrem_scene_remote_raw_callback_end_tx)) { - app->chusen_sub = 1; - subrem_view_remote_set_state(app->subrem_remote_view, 2); - notification_message(app->notifications, &sequence_blink_start_magenta); - } - return true; - } else if(event.event == SubRemCustomEventViewRemoteStartLEFT) { - if(subghz_tx_start_sub( - app, app->subs_preset[2], subrem_scene_remote_raw_callback_end_tx)) { - app->chusen_sub = 2; - subrem_view_remote_set_state(app->subrem_remote_view, 3); + if(subghz_tx_start_sub(app, app->subs_preset[0])) { notification_message(app->notifications, &sequence_blink_start_magenta); } - return true; - } else if(event.event == SubRemCustomEventViewRemoteStartRIGHT) { - if(subghz_tx_start_sub( - app, app->subs_preset[3], subrem_scene_remote_raw_callback_end_tx)) { - app->chusen_sub = 3; - subrem_view_remote_set_state(app->subrem_remote_view, 4); - notification_message(app->notifications, &sequence_blink_start_magenta); - } - return true; - } else if(event.event == SubRemCustomEventViewRemoteStartOK) { - if(subghz_tx_start_sub( - app, app->subs_preset[4], subrem_scene_remote_raw_callback_end_tx)) { - app->chusen_sub = 4; - subrem_view_remote_set_state(app->subrem_remote_view, 5); - notification_message(app->notifications, &sequence_blink_start_magenta); - } - return true; - } else if(event.event == SubRemCustomEventViewRemoteForceStop) { - if(app->tx_running) { - subghz_tx_stop_sub(app); - subrem_view_remote_set_state(app->subrem_remote_view, 0); - } - notification_message(app->notifications, &sequence_blink_stop); - return true; } else if(event.event == SubRemCustomEventViewRemoteStop) { - // if(app->tx_running && - // (app->subs_preset[app->chusen_sub]->type == SubRemSubKeyTypeRawKey)) { - // subghz_tx_stop_sub(app); - // subrem_view_remote_set_state(app->subrem_remote_view, 0); - // } - // notification_message(app->notifications, &sequence_blink_stop); - if(app->tx_running) { - subghz_tx_stop_sub(app); - subrem_view_remote_set_state(app->subrem_remote_view, 0); - } + subghz_tx_stop_sub(app, app->subs_preset[0]); notification_message(app->notifications, &sequence_blink_stop); - return true; } // notification_message(app->notification, &sequence_blink_stop); diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_new/subghz_remote_app.c index 17a559da85..1bfa3a1b3a 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app.c +++ b/applications/external/subghz_remote_new/subghz_remote_app.c @@ -137,8 +137,6 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { app->receiver = subghz_receiver_alloc_init(app->environment); - app->tx_running = false; - scene_manager_next_scene(app->scene_manager, SubRemSceneStart); return app; diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index ef22a9e6d1..7ebad702fb 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -115,10 +115,7 @@ static bool subrem_sub_file_presets_load(SubGhzRemoteApp* app, FlipperFormat* ff return ret; } -bool subghz_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback) { +bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { furi_assert(app); furi_assert(sub_preset); bool ret = false; @@ -155,26 +152,19 @@ bool subghz_tx_start_sub( break; } - if(sub_preset->type == SubRemSubKeyTypeRawKey) { - subghz_protocol_raw_file_encoder_worker_set_callback_end( - (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( - app->transmitter), - callback, - app); - } - furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); ret = true; } } while(false); - app->tx_running = ret; // TODO: + // ret = false; // TODO: return ret; } -void subghz_tx_stop_sub(SubGhzRemoteApp* app) { +void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { furi_assert(app); + furi_assert(sub_preset); //Stop TX furi_hal_subghz_stop_async_tx(); @@ -183,10 +173,7 @@ void subghz_tx_stop_sub(SubGhzRemoteApp* app) { subghz_transmitter_free(app->transmitter); furi_hal_subghz_idle(); - // SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; - // TODO: need saving logic - app->tx_running = false; } static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index 13f3d63c53..d954eca023 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -18,8 +18,6 @@ #include #include -#include - #include #include #include @@ -77,10 +75,6 @@ typedef struct { SubGhzReceiver* receiver; SubGhzTransmitter* transmitter; - bool tx_running; - - uint8_t chusen_sub; - // AvrIspProgrammerView* subghz_remote_programmer_view; // AvrIspReaderView* subghz_remote_reader_view; // AvrIspWriterView* subghz_remote_writer_view; @@ -91,8 +85,5 @@ typedef struct { bool subrem_load_from_file(SubGhzRemoteApp* app); -bool subghz_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback); -void subghz_tx_stop_sub(SubGhzRemoteApp* app); \ No newline at end of file +bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); +void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/transmitter.c b/applications/external/subghz_remote_new/views/transmitter.c index a814880f97..6f43a14066 100644 --- a/applications/external/subghz_remote_new/views/transmitter.c +++ b/applications/external/subghz_remote_new/views/transmitter.c @@ -85,15 +85,6 @@ void subrem_view_remote_add_data_to_show( true); } -void subrem_view_remote_set_state(SubRemViewRemote* subrem_view_remote, uint8_t state) { - furi_assert(subrem_view_remote); - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = state; }, - true); -} - void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); @@ -148,10 +139,10 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180); break; case 3: - canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); break; case 4: - canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); break; case 5: canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7); @@ -186,51 +177,28 @@ bool subrem_view_remote_input(InputEvent* event, void* context) { // furi_string_reset(model->ok_label); }, false); - return false; // TODO: check - } else if(event->key == InputKeyBack && event->type == InputTypeShort) { - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = 0; }, - true); - subrem_view_remote->callback( - SubRemCustomEventViewRemoteForceStop, subrem_view_remote->context); - return true; - } else if(event->key == InputKeyBack) { - return true; + return false; + } else if(event->key == InputKeyUp) { + if(event->type == InputTypePress) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = 1; }, + true); + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context); + return true; + } else if(event->type == InputTypeRelease) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = 0; }, + true); + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStop, subrem_view_remote->context); + return true; + } } - // BACK button processing end - - if(event->key == InputKeyUp && event->type == InputTypePress) { - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context); - return true; - } else if(event->key == InputKeyDown && event->type == InputTypePress) { - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartDOWN, subrem_view_remote->context); - return true; - } else if(event->key == InputKeyLeft && event->type == InputTypePress) { - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartLEFT, subrem_view_remote->context); - return true; - } else if(event->key == InputKeyRight && event->type == InputTypePress) { - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartRIGHT, subrem_view_remote->context); - return true; - } else if(event->key == InputKeyOk && event->type == InputTypePress) { - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartOK, subrem_view_remote->context); - return true; - } else if(event->type == InputTypeRelease) { - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = 0; }, - true); - subrem_view_remote->callback(SubRemCustomEventViewRemoteStop, subrem_view_remote->context); - return true; - } - return true; } diff --git a/applications/external/subghz_remote_new/views/transmitter.h b/applications/external/subghz_remote_new/views/transmitter.h index 64985ff121..a324d09ece 100644 --- a/applications/external/subghz_remote_new/views/transmitter.h +++ b/applications/external/subghz_remote_new/views/transmitter.h @@ -24,6 +24,4 @@ void subrem_view_remote_add_data_to_show( const char* down_label, const char* left_label, const char* right_label, - const char* ok_label); - -void subrem_view_remote_set_state(SubRemViewRemote* subrem_view_remote, uint8_t state); \ No newline at end of file + const char* ok_label); \ No newline at end of file From 24e4c6522122a0429f876df1a8514b4ed832984e Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Wed, 17 May 2023 17:52:46 +0300 Subject: [PATCH 06/92] some improvement and cleanup --- .../helpers/subrem_custom_event.h | 66 +------ .../subghz_remote_new/helpers/subrem_types.h | 43 ++-- .../scenes/subrem_scene_openmapfile.c | 7 +- .../scenes/subrem_scene_remote.c | 165 ++++++++-------- .../scenes/subrem_scene_start.c | 54 ++---- .../subghz_remote_new/subghz_remote_app.c | 48 +---- .../subghz_remote_new/subghz_remote_app_i.c | 183 +++++++++++------- .../subghz_remote_new/subghz_remote_app_i.h | 36 ++-- .../views/{transmitter.c => remote.c} | 157 +++++++++------ .../views/{transmitter.h => remote.h} | 13 +- 10 files changed, 371 insertions(+), 401 deletions(-) rename applications/external/subghz_remote_new/views/{transmitter.c => remote.c} (67%) rename applications/external/subghz_remote_new/views/{transmitter.h => remote.h} (66%) diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h index 0e0ab94ef4..90d60f0269 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h +++ b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h @@ -6,69 +6,17 @@ typedef enum { // SubRemCustomEventManagerSetRAW, //SubmenuIndex - SubmenuIndexOpenMapFile, - SubmenuIndexOpenView, // TODO: temp debug + SubmenuIndexSubRemOpenMapFile, + SubmenuIndexSubRemRemoteView, // TODO: temp debug + SubmenuIndexSubRemAbout, //SubRemCustomEvent - SubRemCustomEventViewRemoteBack = 100, - SubRemCustomEventViewRemoteStartUP, + SubRemCustomEventViewRemoteStartUP = 100, SubRemCustomEventViewRemoteStartDOWN, SubRemCustomEventViewRemoteStartLEFT, SubRemCustomEventViewRemoteStartRIGHT, SubRemCustomEventViewRemoteStartOK, + SubRemCustomEventViewRemoteBack, SubRemCustomEventViewRemoteStop, - - // SubRemCustomEventSceneDeleteSuccess = 100, - // SubRemCustomEventSceneDelete, - // SubRemCustomEventSceneDeleteRAW, - // SubRemCustomEventSceneDeleteRAWBack, - - // SubRemCustomEventSceneReceiverInfoTxStart, - // SubRemCustomEventSceneReceiverInfoTxStop, - // SubRemCustomEventSceneReceiverInfoSave, - // SubRemCustomEventSceneSaveName, - // SubRemCustomEventSceneSaveSuccess, - // SubRemCustomEventSceneShowErrorBack, - // SubRemCustomEventSceneShowErrorOk, - // SubRemCustomEventSceneShowErrorSub, - // SubRemCustomEventSceneShowOnlyRX, - // SubRemCustomEventSceneAnalyzerLock, - // SubRemCustomEventSceneAnalyzerUnlock, - // SubRemCustomEventSceneSettingLock, - - // SubRemCustomEventSceneExit, - // SubRemCustomEventSceneStay, - - // SubRemCustomEventSceneRpcLoad, - // SubRemCustomEventSceneRpcButtonPress, - // SubRemCustomEventSceneRpcButtonRelease, - // SubRemCustomEventSceneRpcSessionClose, - - // SubRemCustomEventViewReceiverOK, - // SubRemCustomEventViewReceiverConfig, - // SubRemCustomEventViewReceiverBack, - // SubRemCustomEventViewReceiverOffDisplay, - // SubRemCustomEventViewReceiverUnlock, - // SubRemCustomEventViewReceiverDeleteItem, - - // SubRemCustomEventViewReadRAWBack, - // SubRemCustomEventViewReadRAWIDLE, - // SubRemCustomEventViewReadRAWREC, - // SubRemCustomEventViewReadRAWConfig, - // SubRemCustomEventViewReadRAWErase, - // SubRemCustomEventViewReadRAWSendStart, - // SubRemCustomEventViewReadRAWSendStop, - // SubRemCustomEventViewReadRAWSave, - // SubRemCustomEventViewReadRAWTXRXStop, - // SubRemCustomEventViewReadRAWMore, - - // SubRemCustomEventViewTransmitterBack, - // SubRemCustomEventViewTransmitterSendStart, - // SubRemCustomEventViewTransmitterSendStop, - // SubRemCustomEventViewTransmitterError, - - // SubRemCustomEventViewFreqAnalOkShort, - // SubRemCustomEventViewFreqAnalOkLong, - - // SubRemCustomEventByteInputDone, -} SubRemCustomEvent; + SubRemCustomEventViewRemoteForcedStop, +} SubRemCustomEvent; \ No newline at end of file diff --git a/applications/external/subghz_remote_new/helpers/subrem_types.h b/applications/external/subghz_remote_new/helpers/subrem_types.h index 56687977fb..0bf31e6a4a 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_types.h +++ b/applications/external/subghz_remote_new/helpers/subrem_types.h @@ -2,50 +2,39 @@ #include #include -/* -#define AVR_ISP_VERSION_APP "0.1" -#define AVR_ISP_DEVELOPED "SkorP" -#define AVR_ISP_GITHUB "https://github.com/flipperdevices/flipperzero-firmware" -#define AVR_ISP_APP_FILE_VERSION 1 -#define AVR_ISP_APP_FILE_TYPE "Flipper Dump AVR" -#define AVR_ISP_APP_EXTENSION ".avr" -*/ +// #define SUBREM_APP_APP_FILE_VERSION 1 +// #define SUBREM_APP_APP_FILE_TYPE "Flipper SubRem Map file" +#define SUBREM_APP_EXTENSION ".txt" -// TODO: rename Filepath -//#define SUBREMOTEMAP_FOLDER "/ext/subghz_remote" -#define SUBGHZ_REMOTE_APP_EXTENSION ".txt" -#define SUBGHZ_REMOTE_APP_PATH_PREFIX "/ext/subghz_remote" +typedef enum { + SubRemSubKeyNameUp = (0U), + SubRemSubKeyNameDown, + SubRemSubKeyNameLeft, + SubRemSubKeyNameRight, + SubRemSubKeyNameOk, + SubRemSubKeyNameMaxCount, +} SubRemSubKeyName; typedef enum { - //SubRemViewVariableItemList, SubRemViewSubmenu, - //SubRemViewProgrammer, - //SubRemViewReader, - //SubRemViewWriter, SubRemViewWidget, SubRemViewPopup, SubRemViewTextInput, SubRemViewIDRemote, - //SubRemViewChipDetect, } SubRemViewID; typedef enum { // Loadin State SubRemSubKeyTypeNoData = 0, - SubRemSubKeyTypeHaveFileName, + // SubRemSubKeyTypeHaveFileName, // Key Type SubRemSubKeyTypeStaticKey = 100, SubRemSubKeyTypeDynamicKey, SubRemSubKeyTypeRawKey, -} SubRemSubKeyType; +} SubRemSubKeyType; // TODO: depricated -/* -typedef enum { - SubRemErrorNoError, - SubRemErrorReading, - SubRemErrorWriting, - SubRemErrorVerification, - SubRemErrorWritingFuse, -} SubRemError;*/ \ No newline at end of file +// typedef enum { +// +// } SubRemLoadMapState; \ No newline at end of file diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c index 67ccca1c39..504bfee2ec 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c @@ -4,14 +4,9 @@ void subrem_scene_openmapfile_on_enter(void* context) { SubGhzRemoteApp* app = context; if(subrem_load_from_file(app)) { - // if(subghz_get_load_type_file(subghz) == SubGhzLoadTypeFileRaw) { - // subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWLoad); - // scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW); - // } else { - // scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSavedMenu); - // } scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); } else { + // TODO: Map Preset Reset scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SubRemSceneStart); } } diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c index 58e253d1ce..a04399cd3f 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c @@ -1,5 +1,9 @@ #include "../subghz_remote_app_i.h" -#include "../views/transmitter.h" +#include "../views/remote.h" + +#include + +#define TAG "SubRemScenRemote" // TODO: // #include @@ -13,61 +17,48 @@ void subrem_scene_remote_callback(SubRemCustomEvent event, void* context) { view_dispatcher_send_custom_event(app->view_dispatcher, event); } -bool subrem_scene_remote_update_data_show(void* context) { +void subrem_scene_remote_raw_callback_end_tx(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventViewRemoteForcedStop); +} + +static uint8_t subrem_scene_remote_event_to_index(SubRemCustomEvent event_id) { + uint8_t ret = 0; + + if(event_id == SubRemCustomEventViewRemoteStartUP) { + ret = SubRemSubKeyNameUp; + } else if(event_id == SubRemCustomEventViewRemoteStartDOWN) { + ret = SubRemSubKeyNameDown; + } else if(event_id == SubRemCustomEventViewRemoteStartLEFT) { + ret = SubRemSubKeyNameLeft; + } else if(event_id == SubRemCustomEventViewRemoteStartRIGHT) { + ret = SubRemSubKeyNameRight; + } else if(event_id == SubRemCustomEventViewRemoteStartOK) { + ret = SubRemSubKeyNameOk; + } + + return ret; +} + +static bool subrem_scene_remote_update_data_show(void* context) { SubGhzRemoteApp* app = context; - //UNUSED(app); bool ret = false; subrem_view_remote_add_data_to_show( - //app->subrem_remote_view, "N/A", "N/A", "N/A", "N/A", "N/A"); app->subrem_remote_view, - // "UP", - // "DOWN", - // "LEFT", - // "RIGHT", - // "OK"); - furi_string_get_cstr(app->subs_preset[0]->label), furi_string_get_cstr(app->subs_preset[1]->label), furi_string_get_cstr(app->subs_preset[2]->label), furi_string_get_cstr(app->subs_preset[3]->label), furi_string_get_cstr(app->subs_preset[4]->label)); - // SubGhzProtocolDecoderBase* decoder = subghz_txrx_get_decoder(app->txrx); - - // if(decoder) { - // FuriString* key_str = furi_string_alloc(); - // FuriString* frequency_str = furi_string_alloc(); - // FuriString* modulation_str = furi_string_alloc(); - - // if(subghz_protocol_decoder_base_deserialize( - // decoder, subghz_txrx_get_fff_data(app->txrx)) == SubGhzProtocolStatusOk) { - // subghz_protocol_decoder_base_get_string(decoder, key_str); - - // subghz_txrx_get_frequency_and_modulation( - // app->txrx, frequency_str, modulation_str, false); - // subghz_view_transmitter_add_data_to_show( - // app->subghz_transmitter, - // furi_string_get_cstr(key_str), - // furi_string_get_cstr(frequency_str), - // furi_string_get_cstr(modulation_str), - // subghz_txrx_protocol_is_transmittable(app->txrx, false)); - // ret = true; - // } - // furi_string_free(frequency_str); - // furi_string_free(modulation_str); - // furi_string_free(key_str); - // } return ret; } void subrem_scene_remote_on_enter(void* context) { SubGhzRemoteApp* app = context; - // TODO: reset custom btns - // keeloq_reset_original_btn(); - // subghz_custom_btns_reset(); - // TODO: init view data if(!subrem_scene_remote_update_data_show(app)) { @@ -84,63 +75,71 @@ void subrem_scene_remote_on_enter(void* context) { bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { SubGhzRemoteApp* app = context; if(event.type == SceneManagerEventTypeCustom) { - // if(event.event == SubGhzCustomEventViewTransmitterSendStart) { - // app->state_notifications = SubGhzNotificationStateIDLE; - - // if(subghz_tx_start(app, subghz_txrx_get_fff_data(app->txrx))) { - // app->state_notifications = SubGhzNotificationStateTx; - // subrem_scene_remote_update_data_show(app); - // DOLPHIN_DEED(DolphinDeedSubGhzSend); - // } - // return true; - // } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) { - // app->state_notifications = SubGhzNotificationStateIDLE; - // subghz_txrx_stop(app->txrx); - // if(subghz_custom_btn_get() != 0) { - // subghz_custom_btn_set(0); - // uint8_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult(); - // furi_hal_subghz_set_rolling_counter_mult(0); - // // Calling restore! - // subghz_tx_start(app, subghz_txrx_get_fff_data(app->txrx)); - // subghz_txrx_stop(app->txrx); - // furi_hal_subghz_set_rolling_counter_mult(tmp_counter); - // } - // return true; - // } else if(event.event == SubRemCustomEventViewRemoteBack) { - // app->state_notifications = SubGhzNotificationStateIDLE; //TODO: notification - scene_manager_search_and_switch_to_previous_scene( - app->scene_manager, SubRemSceneStart); + if(!scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, SubRemSceneOpenMapFile)) { + if(!scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, SubRemSceneStart)) { + scene_manager_stop(app->scene_manager); + view_dispatcher_stop(app->view_dispatcher); + } + } return true; - } else if(event.event == SubRemCustomEventViewRemoteStartUP) { - if(subghz_tx_start_sub(app, app->subs_preset[0])) { + } else if( + event.event == SubRemCustomEventViewRemoteStartUP || + event.event == SubRemCustomEventViewRemoteStartDOWN || + event.event == SubRemCustomEventViewRemoteStartLEFT || + event.event == SubRemCustomEventViewRemoteStartRIGHT || + event.event == SubRemCustomEventViewRemoteStartOK) { + // Start sending sub + subghz_tx_stop_sub(app, true); + app->chusen_sub = subrem_scene_remote_event_to_index(event.event); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateLoading); + if(subghz_tx_start_sub( + app, + app->subs_preset[app->chusen_sub], + subrem_scene_remote_raw_callback_end_tx)) { + subrem_view_remote_set_presed_btn(app->subrem_remote_view, app->chusen_sub); + subrem_view_remote_set_state( + app->subrem_remote_view, SubRemViewRemoteStateSending); notification_message(app->notifications, &sequence_blink_start_magenta); + } else { + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); } - } else if(event.event == SubRemCustomEventViewRemoteStop) { - subghz_tx_stop_sub(app, app->subs_preset[0]); + return true; + } else if(event.event == SubRemCustomEventViewRemoteForcedStop) { + subghz_tx_stop_sub(app, true); + subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + notification_message(app->notifications, &sequence_blink_stop); + return true; + } else if(event.event == SubRemCustomEventViewRemoteStop) { + if(subghz_tx_stop_sub(app, false)) { + subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + + notification_message(app->notifications, &sequence_blink_stop); + } + return true; } - // notification_message(app->notification, &sequence_blink_stop); - - // else if(event.event == SubGhzCustomEventViewTransmitterError) { - // furi_string_set(app->error_str, "Protocol not\nfound!"); - // scene_manager_next_scene(app->scene_manager, SubGhzSceneShowErrorSub); - // } - } else if(event.type == SceneManagerEventTypeTick) { - // if(app->state_notifications == SubGhzNotificationStateTx) { - // notification_message(app->notifications, &sequence_blink_magenta_10); - // } - // return true; } + // } else if(event.type == SceneManagerEventTypeTick) { + // } return false; } void subrem_scene_remote_on_exit(void* context) { SubGhzRemoteApp* app = context; - UNUSED(app); - // TODO: notifications and reset KL - //app->state_notifications = SubGhzNotificationStateIDLE; + subghz_tx_stop_sub(app, true); + + subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + + notification_message(app->notifications, &sequence_blink_stop); + + // TODO: notifications and reset KL // keeloq_reset_mfname(); // keeloq_reset_kl_type(); diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c index 0ad9837e98..75328ab8a7 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c @@ -16,23 +16,17 @@ void subrem_scene_start_on_enter(void* context) { submenu_add_item( submenu, "Open Map File", - SubmenuIndexOpenMapFile, + SubmenuIndexSubRemOpenMapFile, subrem_scene_start_submenu_callback, app); +#if FURI_DEBUG submenu_add_item( - submenu, "Remote", SubmenuIndexOpenView, subrem_scene_start_submenu_callback, app); - // submenu_add_item( - // submenu, - // "ISP Programmer", - // SubmenuIndexSubGhzRemoteProgrammer, - // subrem_scene_start_submenu_callback, - // app); - // submenu_add_item( - // submenu, - // "Wiring", - // SubmenuIndexAvrIsWiring, - // subrem_scene_start_submenu_callback, - // app); + submenu, + "Remote_Debug", + SubmenuIndexSubRemRemoteView, + subrem_scene_start_submenu_callback, + app); +#endif // submenu_add_item( // submenu, // "About", @@ -53,33 +47,21 @@ bool subrem_scene_start_on_event(void* context, SceneManagerEvent event) { bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { - if(event.event == SubmenuIndexOpenMapFile) { + if(event.event == SubmenuIndexSubRemOpenMapFile) { + //scene_manager_set_scene_state(app->scene_manager, SubRemSceneStart, event.event); scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile); consumed = true; - } else if(event.event == SubmenuIndexOpenView) { - scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); - consumed = true; } - // } else if(event.event == SubmenuIndexSubGhzRemoteProgrammer) { - // scene_manager_set_scene_state( - // app->scene_manager, SubRemSceneChipDetect, SubGhzRemoteViewProgrammer); - // scene_manager_next_scene(app->scene_manager, SubRemSceneChipDetect); - // consumed = true; - // } else if(event.event == SubmenuIndexSubGhzRemoteReader) { - // scene_manager_set_scene_state( - // app->scene_manager, SubRemSceneChipDetect, SubGhzRemoteViewReader); - // scene_manager_next_scene(app->scene_manager, SubRemSceneChipDetect); - // consumed = true; - // } else if(event.event == SubmenuIndexSubGhzRemoteWriter) { - // scene_manager_set_scene_state( - // app->scene_manager, SubRemSceneChipDetect, SubGhzRemoteViewWriter); - // scene_manager_next_scene(app->scene_manager, SubRemSceneChipDetect); - // consumed = true; - // } else if(event.event == SubmenuIndexAvrIsWiring) { - // scene_manager_next_scene(app->scene_manager, SubRemSceneWiring); + // } else if(event.event == SubmenuIndexSubRemAbout) { + // scene_manager_next_scene(app->scene_manager, SubRemSceneAbout); // consumed = true; // } - scene_manager_set_scene_state(app->scene_manager, SubRemSceneStart, event.event); +#if FURI_DEBUG + else if(event.event == SubmenuIndexSubRemRemoteView) { + scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); + consumed = true; + } +#endif } return consumed; diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_new/subghz_remote_app.c index 1bfa3a1b3a..ad6fe13fbc 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app.c +++ b/applications/external/subghz_remote_new/subghz_remote_app.c @@ -93,29 +93,8 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { app->view_dispatcher, SubRemViewIDRemote, subrem_view_remote_get_view(app->subrem_remote_view)); - /* - // Reader view - app->subghz_remote_reader_view = subghz_remote_reader_view_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - SubRemViewReader, - subghz_remote_reader_view_get_view(app->subghz_remote_reader_view)); - // Writer view - app->subghz_remote_writer_view = subghz_remote_writer_view_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - SubRemViewWriter, - subghz_remote_writer_view_get_view(app->subghz_remote_writer_view)); - - // Chip detect view - app->subghz_remote_chip_detect_view = subghz_remote_chip_detect_view_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - SubRemViewChipDetect, - subghz_remote_chip_detect_view_get_view(app->subghz_remote_chip_detect_view)); -*/ - for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { app->subs_preset[i] = subrem_sub_file_preset_alloc(); } @@ -137,6 +116,8 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { app->receiver = subghz_receiver_alloc_init(app->environment); + app->tx_running = false; + scene_manager_next_scene(app->scene_manager, SubRemSceneStart); return app; @@ -179,26 +160,10 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { subghz_environment_free(app->environment); subghz_setting_free(app->setting); - for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { subrem_sub_file_preset_free(app->subs_preset[i]); } - // // Reader view - // view_dispatcher_remove_view(app->view_dispatcher, SubRemViewReader); - // subghz_remote_reader_view_free(app->subghz_remote_reader_view); - - // // Writer view - // view_dispatcher_remove_view(app->view_dispatcher, SubRemViewWriter); - // subghz_remote_writer_view_free(app->subghz_remote_writer_view); - - // // Chip detect view - // view_dispatcher_remove_view(app->view_dispatcher, SubRemViewChipDetect); - // subghz_remote_chip_detect_view_free(app->subghz_remote_chip_detect_view); - - // // View dispatcher - // view_dispatcher_free(app->view_dispatcher); - // scene_manager_free(app->scene_manager); - // Notifications furi_record_close(RECORD_NOTIFICATION); app->notifications = NULL; @@ -209,11 +174,6 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { // Path strings furi_string_free(app->file_path); - // Disable 5v power - // if(furi_hal_power_is_otg_enabled()) { - // furi_hal_power_disable_otg(); - // } - free(app); } diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index 7ebad702fb..dac0d15b73 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -7,15 +7,16 @@ #define TAG "SubGhzRemote" -static const char* map_file_labels[SUBREM_MAX_SUB_KEY_COUNT][2] = { - {"UP", "ULABEL"}, - {"DOWN", "DLABEL"}, - {"LEFT", "LLABEL"}, - {"RIGHT", "RLABEL"}, - {"OK", "OKLABEL"}, +static const char* map_file_labels[SubRemSubKeyNameMaxCount][2] = { + [SubRemSubKeyNameUp] = {"UP", "ULABEL"}, + [SubRemSubKeyNameDown] = {"DOWN", "DLABEL"}, + [SubRemSubKeyNameLeft] = {"LEFT", "LLABEL"}, + [SubRemSubKeyNameRight] = {"RIGHT", "RLABEL"}, + [SubRemSubKeyNameOk] = {"OK", "OKLABEL"}, }; -bool subrem_set_preset_data(SubGhzSetting* setting, FreqPreset* freq_preset, const char* preset) { +static bool + subrem_set_preset_data(SubGhzSetting* setting, FreqPreset* freq_preset, const char* preset) { const char* preset_name = ""; if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) { preset_name = "AM270"; @@ -45,7 +46,7 @@ SubRemSubFilePreset* subrem_sub_file_preset_alloc() { sub_preset->protocaol_name = furi_string_alloc(); sub_preset->label = furi_string_alloc_set_str("N/A"); - sub_preset->type = SubRemSubKeyTypeNoData; + sub_preset->type = SubGhzProtocolTypeUnknown; return sub_preset; } @@ -61,7 +62,7 @@ void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { free(sub_preset); } -void subrem_subs_file_preset_reset(SubRemSubFilePreset* sub_preset) { +static void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { furi_assert(sub_preset); furi_string_set_str(sub_preset->label, "N/A"); @@ -71,43 +72,45 @@ void subrem_subs_file_preset_reset(SubRemSubFilePreset* sub_preset) { Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); stream_clean(fff_data_stream); - sub_preset->type = SubRemSubKeyTypeNoData; + sub_preset->type = SubGhzProtocolTypeUnknown; } -void subrem_sub_file_presets_reset(SubGhzRemoteApp* app) { +void subrem_map_preset_reset(SubGhzRemoteApp* app) { furi_assert(app); - for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { - subrem_subs_file_preset_reset(app->subs_preset[i]); + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + subrem_sub_file_preset_reset(app->subs_preset[i]); } } -static bool subrem_sub_file_presets_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { +static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); bool ret = false; - - for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { + SubRemSubFilePreset* sub_preset; + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + sub_preset = app->subs_preset[i]; if(!flipper_format_read_string( - fff_data_file, map_file_labels[i][0], app->subs_preset[i]->file_path)) { + fff_data_file, map_file_labels[i][0], sub_preset->file_path)) { +#if FURO_LOG FURI_LOG_W(TAG, "No file patch for %s", map_file_labels[i][0]); - app->subs_preset[i]->type = SubRemSubKeyTypeNoData; - //continue; +#endif + sub_preset->type = SubGhzProtocolTypeUnknown; } else if(!flipper_format_rewind(fff_data_file)) { // Rewind error - //continue; } else if(!flipper_format_read_string( - fff_data_file, map_file_labels[i][1], app->subs_preset[i]->label)) { + fff_data_file, map_file_labels[i][1], sub_preset->label)) { +#if FURO_LOG FURI_LOG_W(TAG, "No Label for %s", map_file_labels[i][0]); - furi_string_set_str(app->subs_preset[i]->label, "N/A"); +#endif + furi_string_set_str(sub_preset->label, + "N/A"); // TODO: Standart name or part of name } else { FURI_LOG_I( TAG, - // "Loaded %s key \r\nLabel %s file %s", - "Loaded %s key: %s %s", + "%-5s: %s %s", map_file_labels[i][0], - furi_string_get_cstr(app->subs_preset[i]->label), - furi_string_get_cstr(app->subs_preset[i]->file_path)); - app->subs_preset[i]->type = SubRemSubKeyTypeHaveFileName; // TODO: + furi_string_get_cstr(sub_preset->label), + furi_string_get_cstr(sub_preset->file_path)); ret = true; } flipper_format_rewind(fff_data_file); @@ -115,11 +118,20 @@ static bool subrem_sub_file_presets_load(SubGhzRemoteApp* app, FlipperFormat* ff return ret; } -bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { +bool subghz_tx_start_sub( + SubGhzRemoteApp* app, + SubRemSubFilePreset* sub_preset, + SubGhzProtocolEncoderRAWCallbackEnd callback) { furi_assert(app); furi_assert(sub_preset); bool ret = false; + subghz_tx_stop_sub(app, true); + + if(sub_preset->type == SubGhzProtocolTypeUnknown) { + return false; + } + FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); do { @@ -152,19 +164,27 @@ bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) break; } + if(sub_preset->type == SubGhzProtocolTypeRAW) { + subghz_protocol_raw_file_encoder_worker_set_callback_end( + (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( + app->transmitter), + callback, + app); + } + furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); ret = true; } } while(false); - // ret = false; // TODO: + app->tx_running = ret; // TODO: + return ret; } -void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { +static void subghz_tx_stop(SubGhzRemoteApp* app) { furi_assert(app); - furi_assert(sub_preset); //Stop TX furi_hal_subghz_stop_async_tx(); @@ -172,29 +192,46 @@ void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { subghz_transmitter_stop(app->transmitter); subghz_transmitter_free(app->transmitter); furi_hal_subghz_idle(); +} + +bool subghz_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { + furi_assert(app); + + if(forced || (app->subs_preset[app->chusen_sub]->type != SubGhzProtocolTypeRAW)) { + // SubRemSubKeyTypeRawKey)) { + if(app->tx_running) { + subghz_tx_stop(app); + app->tx_running = false; + return true; + } + } + + return false; + + // SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; // TODO: need saving logic } -static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { +static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); FuriString* temp_str = furi_string_alloc(); uint32_t temp_data32; bool ret = false; + bool sub_preset_loaded = false; SubRemSubFilePreset* sub_preset; - for(uint8_t i = 0; i < SUBREM_MAX_SUB_KEY_COUNT; i++) { + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { sub_preset = app->subs_preset[i]; - if(sub_preset->type == SubRemSubKeyTypeNoData) { + sub_preset_loaded = false; + if(furi_string_empty(sub_preset->file_path)) { + // FURI_LOG_I(TAG, "Empty file path"); continue; } do { if(!flipper_format_file_open_existing( fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { - FURI_LOG_E( - TAG, - "Error open file %s", - furi_string_get_cstr(sub_preset->file_path)); // TODO: warning + FURI_LOG_W(TAG, "Error open file %s", furi_string_get_cstr(sub_preset->file_path)); break; } @@ -213,9 +250,9 @@ static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_da //Load frequency if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { - FURI_LOG_W(TAG, "Cannot read frequency. Defaulting to 433.92 MHz"); - sub_preset->freq_preset.frequency = subghz_setting_get_default_frequency( - app->setting); // TODO: Get default from settings + FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); + sub_preset->freq_preset.frequency = + subghz_setting_get_default_frequency(app->setting); } else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { FURI_LOG_E(TAG, "This frequency can only be used for RX"); break; @@ -246,7 +283,6 @@ static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_da //if RAW subghz_protocol_raw_gen_fff_data( fff_data, furi_string_get_cstr(sub_preset->file_path)); - sub_preset->type = SubRemSubKeyTypeRawKey; } else { stream_copy_full( flipper_format_get_raw_stream(fff_data_file), @@ -262,70 +298,82 @@ static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_da if(!protocol) { FURI_LOG_E(TAG, "Protocol not found"); break; - } else if(protocol->flag & SubGhzProtocolFlag_Send) { // FIXME: - - if(protocol->type == SubGhzProtocolTypeStatic) { - sub_preset->type = SubRemSubKeyTypeStaticKey; - } else if(protocol->type == SubGhzProtocolTypeDynamic) { - sub_preset->type = SubRemSubKeyTypeDynamicKey; - } else if(protocol->type == SubGhzProtocolTypeRAW) { - sub_preset->type = SubRemSubKeyTypeRawKey; - // } else if(protocol->type == SubGhzProtocolTypeBinRAW) { // TODO: BINRAW + } else if(protocol->flag & SubGhzProtocolFlag_Send) { + if((protocol->type == SubGhzProtocolTypeStatic) || + (protocol->type == SubGhzProtocolTypeDynamic) || + // (protocol->type == SubGhzProtocolTypeBinRAW) || // TODO: BINRAW + (protocol->type == SubGhzProtocolTypeRAW)) { + sub_preset->type = protocol->type; } else { FURI_LOG_E(TAG, "Unsuported Protocol"); break; } furi_string_set(sub_preset->protocaol_name, temp_str); - } // TODO: check dynamic and protocol found + } else { + FURI_LOG_E(TAG, "Protocol does not support transmission"); + } + sub_preset_loaded = true; ret |= true; - - if(ret) { - FURI_LOG_I(TAG, "Protocol Loaded"); - } +#if FURI_DEBUG + FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); +#endif } while(false); + // TODO: + // Load file state logic + // Label depending on the state + + if(!sub_preset_loaded) { + furi_string_set_str(sub_preset->label, "N/A"); + } + flipper_format_file_close(fff_data_file); } furi_string_free(temp_str); - //ret = false; // TODO: return ret; } bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { furi_assert(app); furi_assert(file_path); - // TODO: drop furi log - FURI_LOG_I(TAG, "Load Map File Start"); // drop +#if FURI_DEBUG + FURI_LOG_I(TAG, "Load Map File Start"); +#endif Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); bool ret = false; - FURI_LOG_I(TAG, "Open Map File.."); // drop - - subrem_sub_file_presets_reset(app); +#if FURI_DEBUG + FURI_LOG_I(TAG, "Open Map File.."); +#endif + subrem_map_preset_reset(app); if(!flipper_format_file_open_existing(fff_data_file, file_path)) { FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); } else { - if(!subrem_sub_file_presets_load(app, fff_data_file)) { - // TODO: error popup or return error type - FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); + if(!subrem_map_preset_load(app, fff_data_file)) { + FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); + // ret = // error for popup } else if( (flipper_format_file_close(fff_data_file)) && - (subrem_sub_presets_check(app, fff_data_file))) { + (subrem_map_preset_check(app, fff_data_file))) { FURI_LOG_I(TAG, "Load Map File Seccesful"); ret = true; } } + // TODO: Pop for error or return error type + if(!ret) { + FURI_LOG_E(TAG, "Broken Map File"); + } + flipper_format_file_close(fff_data_file); flipper_format_free(fff_data_file); furi_record_close(RECORD_STORAGE); - //ret = false; // TODO: return ret; } @@ -344,7 +392,6 @@ bool subrem_load_from_file(SubGhzRemoteApp* app) { if(res) { res = subrem_map_file_load(app, furi_string_get_cstr(app->file_path)); - // FIXME res = subghz_key_load(app, furi_string_get_cstr(app->file_path), true); } furi_string_free(file_path); diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index d954eca023..8941f1401f 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -1,12 +1,12 @@ #pragma once #include "helpers/subrem_types.h" +#include // TODO: -#include "views/transmitter.h" +#include "views/remote.h" #include "scenes/subrem_scene.h" -#include // TODO: #include #include #include @@ -18,21 +18,16 @@ #include #include +#include + #include #include #include #include // FIXME: -// #include "views/subghz_remote_view_programmer.h" -// #include "views/subghz_remote_view_reader.h" -// #include "views/subghz_remote_view_writer.h" -// #include "views/subghz_remote_view_chip_detect.h" - -#define SUBREM_APP_EXTENSION ".txt" -#define SUBREM_APP_FOLDER "/ext/subghz_remote" +#define SUBREM_APP_FOLDER ANY_PATH("subghz_remote") #define SUBGHZ_REMOTE_MAX_LEN_NAME 64 -#define SUBREM_MAX_SUB_KEY_COUNT (5U) typedef struct { uint32_t frequency; @@ -46,7 +41,7 @@ typedef struct { FuriString* file_path; FuriString* protocaol_name; FuriString* label; - SubRemSubKeyType type; + SubGhzProtocolType type; } SubRemSubFilePreset; SubRemSubFilePreset* subrem_sub_file_preset_alloc(); @@ -68,22 +63,25 @@ typedef struct { SubRemViewRemote* subrem_remote_view; - SubRemSubFilePreset* subs_preset[SUBREM_MAX_SUB_KEY_COUNT]; + SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; SubGhzSetting* setting; SubGhzEnvironment* environment; SubGhzReceiver* receiver; SubGhzTransmitter* transmitter; - // AvrIspProgrammerView* subghz_remote_programmer_view; - // AvrIspReaderView* subghz_remote_reader_view; - // AvrIspWriterView* subghz_remote_writer_view; - // AvrIspChipDetectView* subghz_remote_chip_detect_view; + bool tx_running; + + uint8_t chusen_sub; - // AvrIspError error; + // TODO: LoadFileError } SubGhzRemoteApp; bool subrem_load_from_file(SubGhzRemoteApp* app); -bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); -void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); \ No newline at end of file +bool subghz_tx_start_sub( + SubGhzRemoteApp* app, + SubRemSubFilePreset* sub_preset, + SubGhzProtocolEncoderRAWCallbackEnd callback); + +bool subghz_tx_stop_sub(SubGhzRemoteApp* app, bool forced); \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/transmitter.c b/applications/external/subghz_remote_new/views/remote.c similarity index 67% rename from applications/external/subghz_remote_new/views/transmitter.c rename to applications/external/subghz_remote_new/views/remote.c index 6f43a14066..c631c76cc2 100644 --- a/applications/external/subghz_remote_new/views/transmitter.c +++ b/applications/external/subghz_remote_new/views/remote.c @@ -1,27 +1,18 @@ -#include "transmitter.h" +#include "remote.h" #include "../subghz_remote_app_i.h" #include #include #define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 16 + struct SubRemViewRemote { View* view; SubRemViewRemoteCallback callback; void* context; }; -// FIXME: drop -// static char* char_to_str(char* str, int i) { -// char* converted = malloc(sizeof(char) * i + 1); -// memcpy(converted, str, i); - -// converted[i] = '\0'; - -// return converted; -// } // TODO: model - typedef struct { // FuriString* up_label; // FuriString* down_label; @@ -35,6 +26,8 @@ typedef struct { char* right_label; char* ok_label; + SubRemViewRemoteState state; + uint8_t pressed_btn; // bool show_button; // FuriString* temp_button_id; @@ -70,12 +63,6 @@ void subrem_view_remote_add_data_to_show( strncpy(model->right_label, right_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); strncpy(model->ok_label, ok_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - // model->up_label = char_to_str((char*)up_label, 16); - // model->down_label = char_to_str((char*)down_label, 16); - // model->left_label = char_to_str((char*)left_label, 16); - // model->right_label = char_to_str((char*)right_label, 16); - // model->ok_label = char_to_str((char*)ok_label, 16); - // furi_string_set(model->up_label, up_label); // furi_string_set(model->down_label, down_label); // furi_string_set(model->left_label, left_label); @@ -85,6 +72,23 @@ void subrem_view_remote_add_data_to_show( true); } +void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn) { + furi_assert(subrem_view_remote); + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = presed_btn; }, + true); +} + +void subrem_view_remote_set_state( + SubRemViewRemote* subrem_view_remote, + SubRemViewRemoteState state) { + furi_assert(subrem_view_remote); + with_view_model( + subrem_view_remote->view, SubRemViewRemoteModel * model, { model->state = state; }, true); +} + void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); @@ -126,29 +130,44 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Hold=Exit."); //Status text and indicator - // canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, app->send_status); + + //canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, model->state); canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); - switch(model->pressed_btn) { - case 0: - break; - case 1: - canvas_draw_icon(canvas, 116, 17, &I_Pin_arrow_up_7x9); - break; - case 2: - canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180); - break; - case 3: - canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); - break; - case 4: - canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); - break; - case 5: - canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7); - break; - } + if(model->state == SubRemViewRemoteStateIdle) { + canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Idle"); + } else { + switch(model->state) { + case SubRemViewRemoteStateSending: + canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Send"); + break; + case SubRemViewRemoteStateLoading: + canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Load"); + break; + default: + canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Idle"); + break; + } + + switch(model->pressed_btn) { + case SubRemSubKeyNameUp: + canvas_draw_icon(canvas, 116, 17, &I_Pin_arrow_up_7x9); + break; + case SubRemSubKeyNameDown: + canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180); + break; + case SubRemSubKeyNameLeft: + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); + break; + case SubRemSubKeyNameRight: + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); + break; + case SubRemSubKeyNameOk: + canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7); + break; + } + } //Repeat indicator //canvas_draw_str_aligned(canvas, 125, 40, AlignRight, AlignBottom, "Repeat:"); //canvas_draw_icon(canvas, 115, 39, &I_SubGHzRemote_Repeat_12x14); @@ -160,6 +179,7 @@ bool subrem_view_remote_input(InputEvent* event, void* context) { SubRemViewRemote* subrem_view_remote = context; if(event->key == InputKeyBack && event->type == InputTypeLong) { + // TODO: remove reset Debug with_view_model( subrem_view_remote->view, SubRemViewRemoteModel * model, @@ -177,28 +197,47 @@ bool subrem_view_remote_input(InputEvent* event, void* context) { // furi_string_reset(model->ok_label); }, false); - return false; - } else if(event->key == InputKeyUp) { - if(event->type == InputTypePress) { - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = 1; }, - true); - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context); - return true; - } else if(event->type == InputTypeRelease) { - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = 0; }, - true); - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStop, subrem_view_remote->context); - return true; - } + subrem_view_remote->callback(SubRemCustomEventViewRemoteBack, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyBack && event->type == InputTypeShort) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = 0; }, + true); + subrem_view_remote->callback( + SubRemCustomEventViewRemoteForcedStop, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyBack) { + return true; } + // BACK button processing end + + if(event->key == InputKeyUp && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyDown && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartDOWN, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyLeft && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartLEFT, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyRight && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartRIGHT, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyOk && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartOK, subrem_view_remote->context); + return true; + } else if(event->type == InputTypeRelease) { + subrem_view_remote->callback(SubRemCustomEventViewRemoteStop, subrem_view_remote->context); + return true; + } + return true; } @@ -227,6 +266,8 @@ SubRemViewRemote* subrem_view_remote_alloc() { subrem_view_remote->view, SubRemViewRemoteModel * model, { + model->state = SubRemViewRemoteStateIdle; + model->up_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); model->down_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); model->left_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); diff --git a/applications/external/subghz_remote_new/views/transmitter.h b/applications/external/subghz_remote_new/views/remote.h similarity index 66% rename from applications/external/subghz_remote_new/views/transmitter.h rename to applications/external/subghz_remote_new/views/remote.h index a324d09ece..76121cf8a0 100644 --- a/applications/external/subghz_remote_new/views/transmitter.h +++ b/applications/external/subghz_remote_new/views/remote.h @@ -3,6 +3,12 @@ #include #include "../helpers/subrem_custom_event.h" +typedef enum { + SubRemViewRemoteStateIdle, + SubRemViewRemoteStateLoading, + SubRemViewRemoteStateSending, +} SubRemViewRemoteState; + typedef struct SubRemViewRemote SubRemViewRemote; typedef void (*SubRemViewRemoteCallback)(SubRemCustomEvent event, void* context); @@ -24,4 +30,9 @@ void subrem_view_remote_add_data_to_show( const char* down_label, const char* left_label, const char* right_label, - const char* ok_label); \ No newline at end of file + const char* ok_label); + +void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn); +void subrem_view_remote_set_state( + SubRemViewRemote* subrem_view_remote, + SubRemViewRemoteState state); \ No newline at end of file From 64817ac2166b67282534546193020030e985aace Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Thu, 18 May 2023 10:59:08 +0300 Subject: [PATCH 07/92] Move dangerous_settings check --- applications/main/subghz/application.fam | 13 ++++++++- .../main/subghz/subghz_dangerous_freq.c | 23 ++++++++++++++++ .../targets/f7/furi_hal/furi_hal_subghz.c | 27 ++++++++----------- .../targets/f7/furi_hal/furi_hal_subghz.h | 5 ++-- .../targets/f7/furi_hal/furi_hal_subghz_i.h | 3 +++ 5 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 applications/main/subghz/subghz_dangerous_freq.c create mode 100644 firmware/targets/f7/furi_hal/furi_hal_subghz_i.h diff --git a/applications/main/subghz/application.fam b/applications/main/subghz/application.fam index f0dc66e89c..6cd28bd858 100644 --- a/applications/main/subghz/application.fam +++ b/applications/main/subghz/application.fam @@ -10,7 +10,10 @@ App( "cli", "dialogs", ], - provides=["subghz_start"], + provides=[ + "subghz_start", + "subghz_load_dangerous_settings", + ], icon="A_Sub1ghz_14", stack_size=3 * 1024, order=10, @@ -23,3 +26,11 @@ App( requires=["subghz"], order=40, ) + +App( + appid="subghz_load_dangerous_settings", + apptype=FlipperAppType.STARTUP, + entry_point="subghz_dangerous_freq", + requires=["subghz"], + order=41, +) diff --git a/applications/main/subghz/subghz_dangerous_freq.c b/applications/main/subghz/subghz_dangerous_freq.c new file mode 100644 index 0000000000..69a54f04bc --- /dev/null +++ b/applications/main/subghz/subghz_dangerous_freq.c @@ -0,0 +1,23 @@ +#include +#include + +#include + +#include + +void subghz_dangerous_freq() { + bool is_extended_i = false; + + Storage* storage = furi_record_open(RECORD_STORAGE); + FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); + + if(flipper_format_file_open_existing(fff_data_file, "/ext/subghz/assets/dangerous_settings")) { + flipper_format_read_bool( + fff_data_file, "yes_i_want_to_destroy_my_flipper", &is_extended_i, 1); + } + + furi_hal_subghz_set_dangerous_frequency(is_extended_i); + + flipper_format_free(fff_data_file); + furi_record_close(RECORD_STORAGE); +} diff --git a/firmware/targets/f7/furi_hal/furi_hal_subghz.c b/firmware/targets/f7/furi_hal/furi_hal_subghz.c index 6a566d4715..06a7990fbf 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_subghz.c +++ b/firmware/targets/f7/furi_hal/furi_hal_subghz.c @@ -41,6 +41,7 @@ volatile FuriHalSubGhz furi_hal_subghz = { .rolling_counter_mult = 1, .ext_module_power_disabled = false, .timestamp_file_names = false, + .dangerous_frequency_i = false, }; void furi_hal_subghz_select_radio_type(SubGhzRadioType state) { @@ -96,6 +97,10 @@ bool furi_hal_subghz_get_timestamp_file_names(void) { return furi_hal_subghz.timestamp_file_names; } +void furi_hal_subghz_set_dangerous_frequency(bool state_i) { + furi_hal_subghz.dangerous_frequency_i = state_i; +} + void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) { furi_hal_subghz.async_mirror_pin = pin; } @@ -448,29 +453,19 @@ uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value) { } bool furi_hal_subghz_is_tx_allowed(uint32_t value) { - bool is_extended = false; - - // TODO: !!! Move file check to another place - Storage* storage = furi_record_open(RECORD_STORAGE); - FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); - - if(flipper_format_file_open_existing(fff_data_file, "/ext/subghz/assets/dangerous_settings")) { - flipper_format_read_bool( - fff_data_file, "yes_i_want_to_destroy_my_flipper", &is_extended, 1); - } - - flipper_format_free(fff_data_file); - furi_record_close(RECORD_STORAGE); + bool allow_extended_for_int = furi_hal_subghz.dangerous_frequency_i; - if(!(value >= 299999755 && value <= 350000335) && // was increased from 348 to 350 + if(!(allow_extended_for_int) && + !(value >= 299999755 && value <= 350000335) && // was increased from 348 to 350 !(value >= 386999938 && value <= 467750000) && // was increased from 464 to 467.75 - !(value >= 778999847 && value <= 928000000) && !(is_extended)) { + !(value >= 778999847 && value <= 928000000)) { FURI_LOG_I(TAG, "Frequency blocked - outside default range"); return false; } else if( + (allow_extended_for_int) && // !(value >= 281000000 && value <= 361000000) && !(value >= 378000000 && value <= 481000000) && - !(value >= 749000000 && value <= 962000000) && is_extended) { + !(value >= 749000000 && value <= 962000000)) { FURI_LOG_I(TAG, "Frequency blocked - outside dangerous range"); return false; } diff --git a/firmware/targets/f7/furi_hal/furi_hal_subghz.h b/firmware/targets/f7/furi_hal/furi_hal_subghz.h index 35eab4faf8..0ef7bd90a6 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_subghz.h +++ b/firmware/targets/f7/furi_hal/furi_hal_subghz.h @@ -78,8 +78,9 @@ typedef struct { FuriHalSpiBusHandle* spi_bus_handle; const GpioPin* cc1101_g0_pin; uint8_t rolling_counter_mult; - bool ext_module_power_disabled; - bool timestamp_file_names; + bool ext_module_power_disabled : 1; + bool timestamp_file_names : 1; + bool dangerous_frequency_i : 1; } FuriHalSubGhz; extern volatile FuriHalSubGhz furi_hal_subghz; diff --git a/firmware/targets/f7/furi_hal/furi_hal_subghz_i.h b/firmware/targets/f7/furi_hal/furi_hal_subghz_i.h new file mode 100644 index 0000000000..e7fe2602f7 --- /dev/null +++ b/firmware/targets/f7/furi_hal/furi_hal_subghz_i.h @@ -0,0 +1,3 @@ +#pragma once + +void furi_hal_subghz_set_dangerous_frequency(bool state_i); \ No newline at end of file From 9da2e4fae876ea1c83a24e38fac389e3c68e7efa Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Thu, 18 May 2023 12:01:17 +0300 Subject: [PATCH 08/92] add save dynamic --- .../subghz_remote_new/application.fam | 1 + .../scenes/subrem_scene_openmapfile.c | 20 +++++++- .../subghz_remote_new/subghz_remote_app_i.c | 46 ++++++++++++++++++- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/applications/external/subghz_remote_new/application.fam b/applications/external/subghz_remote_new/application.fam index 4f633b9610..389f02b61a 100644 --- a/applications/external/subghz_remote_new/application.fam +++ b/applications/external/subghz_remote_new/application.fam @@ -7,6 +7,7 @@ App( "gui", "dialogs", ], + cdefines=["SUBREM_LIGHT"], icon="A_SubGHzRemote_14", stack_size=4 * 1024, order=12, diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c index 504bfee2ec..cb93134ab6 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c @@ -7,7 +7,25 @@ void subrem_scene_openmapfile_on_enter(void* context) { scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); } else { // TODO: Map Preset Reset - scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SubRemSceneStart); + + // #if SUBREM_LIGHT + // dialog_message_show_storage_error(app->dialogs, "Can't load\nMap file"); + // #else + DialogMessage* message = dialog_message_alloc(); + + dialog_message_set_header(message, "Map File Error", 64, 8, AlignCenter, AlignCenter); + dialog_message_set_text(message, "Can't load\nMap file", 64, 32, AlignCenter, AlignCenter); + dialog_message_set_buttons(message, "Back", NULL, NULL); + dialog_message_show(app->dialogs, message); + + dialog_message_free(message); + // #endif + + if(!scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, SubRemSceneStart)) { + scene_manager_stop(app->scene_manager); + view_dispatcher_stop(app->view_dispatcher); + } } } diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index dac0d15b73..da3f317174 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -118,6 +118,43 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data return ret; } +bool subghz_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { + // furi_assert(subghz); + furi_assert(flipper_format); + furi_assert(dev_file_name); + + Storage* storage = furi_record_open(RECORD_STORAGE); + Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); + + bool saved = false; + FuriString* file_dir = furi_string_alloc(); + + path_extract_dirname(dev_file_name, file_dir); + do { + //removing additional fields + flipper_format_delete_key(flipper_format, "Repeat"); + //flipper_format_delete_key(flipper_format, "Manufacture"); + + // Create subghz folder directory if necessary + // if(!storage_simply_mkdir(storage, furi_string_get_cstr(file_dir))) { + // dialog_message_show_storage_error(subghz->dialogs, "Cannot create\nfolder"); + // break; + // } + + if(!storage_simply_remove(storage, dev_file_name)) { + break; + } + //ToDo check Write + stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); + stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); + + saved = true; + } while(0); + furi_string_free(file_dir); + furi_record_close(RECORD_STORAGE); + return saved; +} + bool subghz_tx_start_sub( SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset, @@ -196,11 +233,18 @@ static void subghz_tx_stop(SubGhzRemoteApp* app) { bool subghz_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { furi_assert(app); + SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; - if(forced || (app->subs_preset[app->chusen_sub]->type != SubGhzProtocolTypeRAW)) { + if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) { // SubRemSubKeyTypeRawKey)) { if(app->tx_running) { subghz_tx_stop(app); + + if(sub_preset->type == SubGhzProtocolTypeDynamic) { + subghz_save_protocol_to_file( + sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); + } + app->tx_running = false; return true; } From e8264dc6e73005a714145dfc667b28d1c57ba13b Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Thu, 18 May 2023 13:48:25 +0300 Subject: [PATCH 09/92] subghz_remote_app --- .../main/subghz_remote/application.fam | 7 +- .../helpers/subrem_custom_event.h | 18 + .../main/subghz_remote/helpers/subrem_types.h | 32 + .../main/subghz_remote/scenes/subrem_scene.c | 30 + .../main/subghz_remote/scenes/subrem_scene.h | 29 + .../scenes/subrem_scene_config.h | 3 + .../scenes/subrem_scene_openmapfile.c | 41 + .../scenes/subrem_scene_remote.c | 129 ++ .../subghz_remote/scenes/subrem_scene_start.c | 74 ++ .../main/subghz_remote/subghz_remote_app.c | 1121 ++--------------- .../main/subghz_remote/subghz_remote_app_i.c | 449 +++++++ .../main/subghz_remote/subghz_remote_app_i.h | 84 ++ .../main/subghz_remote/views/remote.c | 302 +++++ .../main/subghz_remote/views/remote.h | 38 + 14 files changed, 1323 insertions(+), 1034 deletions(-) create mode 100644 applications/main/subghz_remote/helpers/subrem_custom_event.h create mode 100644 applications/main/subghz_remote/helpers/subrem_types.h create mode 100644 applications/main/subghz_remote/scenes/subrem_scene.c create mode 100644 applications/main/subghz_remote/scenes/subrem_scene.h create mode 100644 applications/main/subghz_remote/scenes/subrem_scene_config.h create mode 100644 applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c create mode 100644 applications/main/subghz_remote/scenes/subrem_scene_remote.c create mode 100644 applications/main/subghz_remote/scenes/subrem_scene_start.c create mode 100644 applications/main/subghz_remote/subghz_remote_app_i.c create mode 100644 applications/main/subghz_remote/subghz_remote_app_i.h create mode 100644 applications/main/subghz_remote/views/remote.c create mode 100644 applications/main/subghz_remote/views/remote.h diff --git a/applications/main/subghz_remote/application.fam b/applications/main/subghz_remote/application.fam index e09f8500ff..e785043e64 100644 --- a/applications/main/subghz_remote/application.fam +++ b/applications/main/subghz_remote/application.fam @@ -3,7 +3,10 @@ App( name="Sub-GHz Remote", apptype=FlipperAppType.APP, entry_point="subghz_remote_app", - cdefines=["APP_SUBGHZREMOTE"], + cdefines=[ + "APP_SUBGHZREMOTE", + "SUBREM_LIGHT", + ], requires=[ "gui", "dialogs", @@ -11,4 +14,4 @@ App( icon="A_SubGHzRemote_14", stack_size=4 * 1024, order=11, -) +) \ No newline at end of file diff --git a/applications/main/subghz_remote/helpers/subrem_custom_event.h b/applications/main/subghz_remote/helpers/subrem_custom_event.h new file mode 100644 index 0000000000..46ab8ad547 --- /dev/null +++ b/applications/main/subghz_remote/helpers/subrem_custom_event.h @@ -0,0 +1,18 @@ +#pragma once + +typedef enum { + //SubmenuIndex + SubmenuIndexSubRemOpenMapFile, + SubmenuIndexSubRemRemoteView, + SubmenuIndexSubRemAbout, + + //SubRemCustomEvent + SubRemCustomEventViewRemoteStartUP = 100, + SubRemCustomEventViewRemoteStartDOWN, + SubRemCustomEventViewRemoteStartLEFT, + SubRemCustomEventViewRemoteStartRIGHT, + SubRemCustomEventViewRemoteStartOK, + SubRemCustomEventViewRemoteBack, + SubRemCustomEventViewRemoteStop, + SubRemCustomEventViewRemoteForcedStop, +} SubRemCustomEvent; \ No newline at end of file diff --git a/applications/main/subghz_remote/helpers/subrem_types.h b/applications/main/subghz_remote/helpers/subrem_types.h new file mode 100644 index 0000000000..1b99aac6d2 --- /dev/null +++ b/applications/main/subghz_remote/helpers/subrem_types.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include + +// TODO: File version/type logic +// #define SUBREM_APP_APP_FILE_VERSION 1 +// #define SUBREM_APP_APP_FILE_TYPE "Flipper SubRem Map file" +#define SUBREM_APP_EXTENSION ".txt" + +typedef enum { + SubRemSubKeyNameUp = (0U), + SubRemSubKeyNameDown, + SubRemSubKeyNameLeft, + SubRemSubKeyNameRight, + SubRemSubKeyNameOk, + SubRemSubKeyNameMaxCount, +} SubRemSubKeyName; + +typedef enum { + SubRemViewSubmenu, + SubRemViewWidget, + SubRemViewPopup, + SubRemViewTextInput, + SubRemViewIDRemote, +} SubRemViewID; + +typedef enum { + SubRemLoadMapStateBack = 0, + SubRemLoadMapStateError, + SubRemLoadMapStateOK, +} SubRemLoadMapState; \ No newline at end of file diff --git a/applications/main/subghz_remote/scenes/subrem_scene.c b/applications/main/subghz_remote/scenes/subrem_scene.c new file mode 100644 index 0000000000..c45285b967 --- /dev/null +++ b/applications/main/subghz_remote/scenes/subrem_scene.c @@ -0,0 +1,30 @@ +#include "../subghz_remote_app_i.h" + +// Generate scene on_enter handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, +void (*const subrem_scene_on_enter_handlers[])(void*) = { +#include "subrem_scene_config.h" +}; +#undef ADD_SCENE + +// Generate scene on_event handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, +bool (*const subrem_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = { +#include "subrem_scene_config.h" +}; +#undef ADD_SCENE + +// Generate scene on_exit handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, +void (*const subrem_scene_on_exit_handlers[])(void* context) = { +#include "subrem_scene_config.h" +}; +#undef ADD_SCENE + +// Initialize scene handlers configuration structure +const SceneManagerHandlers subrem_scene_handlers = { + .on_enter_handlers = subrem_scene_on_enter_handlers, + .on_event_handlers = subrem_scene_on_event_handlers, + .on_exit_handlers = subrem_scene_on_exit_handlers, + .scene_num = SubRemSceneNum, +}; diff --git a/applications/main/subghz_remote/scenes/subrem_scene.h b/applications/main/subghz_remote/scenes/subrem_scene.h new file mode 100644 index 0000000000..5c01f8ca51 --- /dev/null +++ b/applications/main/subghz_remote/scenes/subrem_scene.h @@ -0,0 +1,29 @@ +#pragma once + +#include + +// Generate scene id and total number +#define ADD_SCENE(prefix, name, id) SubRemScene##id, +typedef enum { +#include "subrem_scene_config.h" + SubRemSceneNum, +} SubRemScene; +#undef ADD_SCENE + +extern const SceneManagerHandlers subrem_scene_handlers; + +// Generate scene on_enter handlers declaration +#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); +#include "subrem_scene_config.h" +#undef ADD_SCENE + +// Generate scene on_event handlers declaration +#define ADD_SCENE(prefix, name, id) \ + bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); +#include "subrem_scene_config.h" +#undef ADD_SCENE + +// Generate scene on_exit handlers declaration +#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); +#include "subrem_scene_config.h" +#undef ADD_SCENE diff --git a/applications/main/subghz_remote/scenes/subrem_scene_config.h b/applications/main/subghz_remote/scenes/subrem_scene_config.h new file mode 100644 index 0000000000..93d4de642e --- /dev/null +++ b/applications/main/subghz_remote/scenes/subrem_scene_config.h @@ -0,0 +1,3 @@ +ADD_SCENE(subrem, start, Start) +ADD_SCENE(subrem, openmapfile, OpenMapFile) +ADD_SCENE(subrem, remote, Remote) \ No newline at end of file diff --git a/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c b/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c new file mode 100644 index 0000000000..3391845e12 --- /dev/null +++ b/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c @@ -0,0 +1,41 @@ +#include "../subghz_remote_app_i.h" + +void subrem_scene_openmapfile_on_enter(void* context) { + SubGhzRemoteApp* app = context; + SubRemLoadMapState load_state = subrem_load_from_file(app); + + if(load_state == SubRemLoadMapStateError) { +#ifdef SUBREM_LIGHT + dialog_message_show_storage_error(app->dialogs, "Can't load\nMap file"); +#else + DialogMessage* message = dialog_message_alloc(); + + dialog_message_set_header(message, "Map File Error", 64, 8, AlignCenter, AlignCenter); + dialog_message_set_text(message, "Can't load\nMap file", 64, 32, AlignCenter, AlignCenter); + dialog_message_set_buttons(message, "Back", NULL, NULL); + dialog_message_show(app->dialogs, message); + + dialog_message_free(message); +#endif + } + if(load_state == SubRemLoadMapStateOK) { + scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); + } else { + // TODO: Map Preset Reset + if(!scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, SubRemSceneStart)) { + scene_manager_stop(app->scene_manager); + view_dispatcher_stop(app->view_dispatcher); + } + } +} + +bool subrem_scene_openmapfile_on_event(void* context, SceneManagerEvent event) { + UNUSED(context); + UNUSED(event); + return false; +} + +void subrem_scene_openmapfile_on_exit(void* context) { + UNUSED(context); +} diff --git a/applications/main/subghz_remote/scenes/subrem_scene_remote.c b/applications/main/subghz_remote/scenes/subrem_scene_remote.c new file mode 100644 index 0000000000..d543ca999f --- /dev/null +++ b/applications/main/subghz_remote/scenes/subrem_scene_remote.c @@ -0,0 +1,129 @@ +#include "../subghz_remote_app_i.h" +#include "../views/remote.h" + +#include + +#define TAG "SubRemScenRemote" + +void subrem_scene_remote_callback(SubRemCustomEvent event, void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, event); +} + +void subrem_scene_remote_raw_callback_end_tx(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventViewRemoteForcedStop); +} + +static uint8_t subrem_scene_remote_event_to_index(SubRemCustomEvent event_id) { + uint8_t ret = 0; + + if(event_id == SubRemCustomEventViewRemoteStartUP) { + ret = SubRemSubKeyNameUp; + } else if(event_id == SubRemCustomEventViewRemoteStartDOWN) { + ret = SubRemSubKeyNameDown; + } else if(event_id == SubRemCustomEventViewRemoteStartLEFT) { + ret = SubRemSubKeyNameLeft; + } else if(event_id == SubRemCustomEventViewRemoteStartRIGHT) { + ret = SubRemSubKeyNameRight; + } else if(event_id == SubRemCustomEventViewRemoteStartOK) { + ret = SubRemSubKeyNameOk; + } + + return ret; +} + +static bool subrem_scene_remote_update_data_show(void* context) { + SubGhzRemoteApp* app = context; + bool ret = false; + + subrem_view_remote_add_data_to_show( + app->subrem_remote_view, + furi_string_get_cstr(app->subs_preset[0]->label), + furi_string_get_cstr(app->subs_preset[1]->label), + furi_string_get_cstr(app->subs_preset[2]->label), + furi_string_get_cstr(app->subs_preset[3]->label), + furi_string_get_cstr(app->subs_preset[4]->label)); + + return ret; +} + +void subrem_scene_remote_on_enter(void* context) { + SubGhzRemoteApp* app = context; + + subrem_scene_remote_update_data_show(app); + + subrem_view_remote_set_callback(app->subrem_remote_view, subrem_scene_remote_callback, app); + + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDRemote); +} + +bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { + SubGhzRemoteApp* app = context; + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubRemCustomEventViewRemoteBack) { + if(!scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, SubRemSceneOpenMapFile)) { + if(!scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, SubRemSceneStart)) { + scene_manager_stop(app->scene_manager); + view_dispatcher_stop(app->view_dispatcher); + } + } + return true; + } else if( + event.event == SubRemCustomEventViewRemoteStartUP || + event.event == SubRemCustomEventViewRemoteStartDOWN || + event.event == SubRemCustomEventViewRemoteStartLEFT || + event.event == SubRemCustomEventViewRemoteStartRIGHT || + event.event == SubRemCustomEventViewRemoteStartOK) { + // Start sending sub + subrem_tx_stop_sub(app, true); + app->chusen_sub = subrem_scene_remote_event_to_index(event.event); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateLoading); + if(subrem_tx_start_sub( + app, + app->subs_preset[app->chusen_sub], + subrem_scene_remote_raw_callback_end_tx)) { + subrem_view_remote_set_presed_btn(app->subrem_remote_view, app->chusen_sub); + subrem_view_remote_set_state( + app->subrem_remote_view, SubRemViewRemoteStateSending); + notification_message(app->notifications, &sequence_blink_start_magenta); + } else { + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + } + return true; + } else if(event.event == SubRemCustomEventViewRemoteForcedStop) { + subrem_tx_stop_sub(app, true); + subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + + notification_message(app->notifications, &sequence_blink_stop); + return true; + } else if(event.event == SubRemCustomEventViewRemoteStop) { + if(subrem_tx_stop_sub(app, false)) { + subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + + notification_message(app->notifications, &sequence_blink_stop); + } + return true; + } + } + // } else if(event.type == SceneManagerEventTypeTick) { + // } + return false; +} + +void subrem_scene_remote_on_exit(void* context) { + SubGhzRemoteApp* app = context; + + subrem_tx_stop_sub(app, true); + + subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + + notification_message(app->notifications, &sequence_blink_stop); +} diff --git a/applications/main/subghz_remote/scenes/subrem_scene_start.c b/applications/main/subghz_remote/scenes/subrem_scene_start.c new file mode 100644 index 0000000000..962eda54ca --- /dev/null +++ b/applications/main/subghz_remote/scenes/subrem_scene_start.c @@ -0,0 +1,74 @@ +#include "../subghz_remote_app_i.h" +#include "../helpers/subrem_custom_event.h" + +void subrem_scene_start_submenu_callback(void* context, uint32_t index) { + furi_assert(context); + SubGhzRemoteApp* app = context; + + view_dispatcher_send_custom_event(app->view_dispatcher, index); +} + +void subrem_scene_start_on_enter(void* context) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + Submenu* submenu = app->submenu; + submenu_add_item( + submenu, + "Open Map File", + SubmenuIndexSubRemOpenMapFile, + subrem_scene_start_submenu_callback, + app); +#if FURI_DEBUG + submenu_add_item( + submenu, + "Remote_Debug", + SubmenuIndexSubRemRemoteView, + subrem_scene_start_submenu_callback, + app); +#endif + // submenu_add_item( + // submenu, + // "About", + // SubmenuIndexSubGhzRemoteAbout, + // subrem_scene_start_submenu_callback, + // app); + + submenu_set_selected_item( + submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); + + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewSubmenu); +} + +bool subrem_scene_start_on_event(void* context, SceneManagerEvent event) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubmenuIndexSubRemOpenMapFile) { + scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile); + consumed = true; + } + // } else if(event.event == SubmenuIndexSubRemAbout) { + // scene_manager_next_scene(app->scene_manager, SubRemSceneAbout); + // consumed = true; + // } +#if FURI_DEBUG + else if(event.event == SubmenuIndexSubRemRemoteView) { + scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); + consumed = true; + } +#endif + } + + return consumed; +} + +void subrem_scene_start_on_exit(void* context) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + submenu_reset(app->submenu); +} diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index 8cef4da3a7..de80c9cdd2 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -1,796 +1,110 @@ -#include +#include "subghz_remote_app_i.h" -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include #include -#include -#include -#include - -#include - -#define SUBREMOTEMAP_FOLDER "/ext/subghz_remote" -#define SUBREMOTEMAP_EXTENSION ".txt" - -#define TAG "SubGHzRemote" - -typedef struct { - uint32_t frequency; - FuriString* name; - - FuriString* protocol; - uint32_t repeat; - - uint8_t* data; - size_t data_size; - - SubGhzProtocolDecoderBase* decoder; -} SubRemotePreset; - -typedef struct { - FuriMutex* model_mutex; - - FuriMessageQueue* input_queue; - - ViewPort* view_port; - Gui* gui; - - SubGhzSetting* setting; - SubGhzEnvironment* environment; - SubGhzReceiver* subghz_receiver; - NotificationApp* notification; - SubRemotePreset* txpreset; - - FuriString* up_file; - FuriString* down_file; - FuriString* left_file; - FuriString* right_file; - FuriString* ok_file; - - FuriString* file_path; - - char* up_label; - char* down_label; - char* left_label; - char* right_label; - char* ok_label; - - int up_enabled; - int down_enabled; - int left_enabled; - int right_enabled; - int ok_enabled; - - char* send_status; - int send_status_c; - int processing; - - SubGhzTransmitter* tx_transmitter; - FlipperFormat* tx_fff_data; - const char* tx_file_path; - int button; - - int file_result; - bool tx_not_allowed; - - FuriString* signal; -} SubGHzRemote; - -SubRemotePreset* subghz_remote_preset_alloc(void) { - SubRemotePreset* preset = malloc(sizeof(SubRemotePreset)); - preset->name = furi_string_alloc(); - preset->protocol = furi_string_alloc(); - preset->repeat = 200; - return preset; -} - -void subghz_remote_preset_free(SubRemotePreset* preset) { - furi_string_free(preset->name); - furi_string_free(preset->protocol); - free(preset); -} - -static char* char_to_str(char* str, int i) { - char* converted = malloc(sizeof(char) * i + 1); - memcpy(converted, str, i); - - converted[i] = '\0'; - - return converted; -} - -//get filename without path -static char* extract_filename(const char* name, int len) { - FuriString* tmp; - tmp = furi_string_alloc(); - - //remove path - path_extract_filename_no_ext(name, tmp); - - return char_to_str((char*)furi_string_get_cstr(tmp), len); -} - -static void cfg_read_file_path( - FlipperFormat* fff_file, - FuriString* text_file_path, - char** text_file_label, - const char* read_key, - int* is_enabled) { - if(!flipper_format_read_string(fff_file, read_key, text_file_path)) { - FURI_LOG_W(TAG, "Could not read %s string", read_key); - *text_file_label = "N/A"; - *is_enabled = 0; - } else { - *text_file_label = extract_filename(furi_string_get_cstr(text_file_path), 16); - //FURI_LOG_D(TAG, "%s file: %s", read_key, furi_string_get_cstr(text_file_path)); - *is_enabled = 1; - } - flipper_format_rewind(fff_file); -} - -static void cfg_read_file_label( - FlipperFormat* fff_file, - char** text_file_label, - const char* read_key, - bool is_enabled) { - FuriString* temp_label = furi_string_alloc(); - - if(!flipper_format_read_string(fff_file, read_key, temp_label)) { - FURI_LOG_W(TAG, "Could not read %s string", read_key); - } else { - if(is_enabled == 1) { - *text_file_label = char_to_str((char*)furi_string_get_cstr(temp_label), 16); - } - //FURI_LOG_D(TAG, "%s label: %s", read_key, *text_file_label); - } - flipper_format_rewind(fff_file); - furi_string_free(temp_label); -} - -/* - * check that map file exists - * assign variables to values within map file - * set missing filenames to N/A - * set filename as label if label definitions are missing - * set error flag if all buttons are N/A - * set error flag if missing map file - */ - -void subghz_remote_cfg_set_check(SubGHzRemote* app, FuriString* file_name) { - Storage* storage = furi_record_open(RECORD_STORAGE); - FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); - - app->file_result = 1; - - app->up_enabled = 0; - app->down_enabled = 0; - app->left_enabled = 0; - app->right_enabled = 0; - app->ok_enabled = 0; - - //check that map file exists - if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) { - FURI_LOG_E(TAG, "Could not open MAP file %s", furi_string_get_cstr(file_name)); - } else { - //Filename Assignment/Check Start - - //assign variables to values within map file - //set missing filenames to N/A - cfg_read_file_path(fff_data_file, app->up_file, &app->up_label, "UP", &app->up_enabled); - - cfg_read_file_path( - fff_data_file, app->down_file, &app->down_label, "DOWN", &app->down_enabled); - - cfg_read_file_path( - fff_data_file, app->left_file, &app->left_label, "LEFT", &app->left_enabled); - - cfg_read_file_path( - fff_data_file, app->right_file, &app->right_label, "RIGHT", &app->right_enabled); - - cfg_read_file_path(fff_data_file, app->ok_file, &app->ok_label, "OK", &app->ok_enabled); - - //File definitions are done. - //File checks will follow after label assignment in order to close the universal_rf_map file without the need to reopen it again. - - //Label Assignment/Check Start - - cfg_read_file_label(fff_data_file, &app->up_label, "ULABEL", app->up_enabled); - cfg_read_file_label(fff_data_file, &app->down_label, "DLABEL", app->down_enabled); - cfg_read_file_label(fff_data_file, &app->left_label, "LLABEL", app->left_enabled); - cfg_read_file_label(fff_data_file, &app->right_label, "RLABEL", app->right_enabled); - cfg_read_file_label(fff_data_file, &app->ok_label, "OKLABEL", app->ok_enabled); - } - - flipper_format_file_close(fff_data_file); - flipper_format_free(fff_data_file); - //File Existence Check - //Check each file definition if not already set to "N/A" - - //determine if files exist. - //determine whether or not to continue to launch app with missing variables - //if 5 files are missing, throw error - - //if button is still enabled, check that file exists - if(app->up_enabled == 1) { - furi_string_set(file_name, app->up_file); - fff_data_file = flipper_format_file_alloc(storage); - - if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) { - FURI_LOG_W(TAG, "Could not open UP file %s", furi_string_get_cstr(file_name)); - - //disable button, and set label to "N/A" - app->up_enabled = 0; - app->up_label = "N/A"; - } - - //close the file - flipper_format_file_close(fff_data_file); - flipper_format_free(fff_data_file); - } - - if(app->down_enabled == 1) { - furi_string_set(file_name, app->down_file); - fff_data_file = flipper_format_file_alloc(storage); - - if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) { - FURI_LOG_W(TAG, "Could not open DOWN file %s", furi_string_get_cstr(file_name)); - - app->down_enabled = 0; - app->down_label = "N/A"; - } - - flipper_format_file_close(fff_data_file); - flipper_format_free(fff_data_file); - } - - if(app->left_enabled == 1) { - furi_string_set(file_name, app->left_file); - fff_data_file = flipper_format_file_alloc(storage); - - if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) { - FURI_LOG_W(TAG, "Could not open LEFT file %s", furi_string_get_cstr(file_name)); - - app->left_enabled = 0; - app->left_label = "N/A"; - } - - flipper_format_file_close(fff_data_file); - flipper_format_free(fff_data_file); - } - - if(app->right_enabled == 1) { - furi_string_set(file_name, app->right_file); - fff_data_file = flipper_format_file_alloc(storage); - - if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) { - FURI_LOG_W(TAG, "Could not open RIGHT file %s", furi_string_get_cstr(file_name)); - - app->right_enabled = 0; - app->right_label = "N/A"; - } - - flipper_format_file_close(fff_data_file); - flipper_format_free(fff_data_file); - } - - if(app->ok_enabled == 1) { - furi_string_set(file_name, app->ok_file); - fff_data_file = flipper_format_file_alloc(storage); - - if(!flipper_format_file_open_existing(fff_data_file, furi_string_get_cstr(file_name))) { - FURI_LOG_W(TAG, "Could not open OK file %s", furi_string_get_cstr(file_name)); - - app->ok_enabled = 0; - app->ok_label = "N/A"; - } - - flipper_format_file_close(fff_data_file); - flipper_format_free(fff_data_file); - } - - furi_record_close(RECORD_STORAGE); - - if(app->up_enabled == 0 && app->down_enabled == 0 && app->left_enabled == 0 && - app->right_enabled == 0 && app->ok_enabled == 0) { - app->file_result = 1; - } else { - app->file_result = 2; - } +static bool subghz_remote_app_custom_event_callback(void* context, uint32_t event) { + furi_assert(context); + SubGhzRemoteApp* app = context; + return scene_manager_handle_custom_event(app->scene_manager, event); } -static void subghz_remote_end_send(SubGHzRemote* app) { - app->processing = 0; +static bool subghz_remote_app_back_event_callback(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + return scene_manager_handle_back_event(app->scene_manager); } -bool subghz_remote_set_preset(SubRemotePreset* p, const char* preset) { - if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) { - furi_string_set(p->name, "AM270"); - } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) { - furi_string_set(p->name, "AM650"); - } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) { - furi_string_set(p->name, "FM238"); - } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) { - furi_string_set(p->name, "FM476"); - } else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) { - FURI_LOG_E(TAG, "Custom preset unsupported now"); - return false; - // furi_string_set(p->name, "CUSTOM"); - } else { - FURI_LOG_E(TAG, "Unsupported preset"); - return false; - } - return true; -} - -bool subghz_remote_key_load( - SubRemotePreset* preset, - FlipperFormat* fff_file, - FlipperFormat* fff_data, - SubGhzSetting* setting, - SubGhzReceiver* receiver, - const char* path) { - // - if(!flipper_format_rewind(fff_file)) { - FURI_LOG_E(TAG, "Rewind error"); - return false; - } - - FuriString* temp_str; - temp_str = furi_string_alloc(); - - bool res = false; - - subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); - keeloq_reset_original_btn(); - subghz_custom_btns_reset(); - - do { - // load frequency from file - if(!flipper_format_read_uint32(fff_file, "Frequency", &preset->frequency, 1)) { - FURI_LOG_W(TAG, "Cannot read frequency. Defaulting to 433.92 MHz"); - preset->frequency = 433920000; - } - - // load preset from file - if(!flipper_format_read_string(fff_file, "Preset", temp_str)) { - FURI_LOG_W(TAG, "Could not read Preset. Defaulting to Ook650Async"); - furi_string_set(temp_str, "FuriHalSubGhzPresetOok650Async"); - } - if(!subghz_remote_set_preset(preset, furi_string_get_cstr(temp_str))) { - FURI_LOG_E(TAG, "Could not set preset"); - break; - } - if(!strcmp(furi_string_get_cstr(temp_str), "FuriHalSubGhzPresetCustom")) { - // TODO: check if preset is custom - FURI_LOG_E(TAG, "Could not use custom preset"); - break; - } - size_t preset_index = - subghz_setting_get_inx_preset_by_name(setting, furi_string_get_cstr(preset->name)); - preset->data = subghz_setting_get_preset_data(setting, preset_index); - preset->data_size = subghz_setting_get_preset_data_size(setting, preset_index); - - // load protocol from file - if(!flipper_format_read_string(fff_file, "Protocol", preset->protocol)) { - FURI_LOG_E(TAG, "Could not read Protocol."); - break; - } - if(!flipper_format_rewind(fff_data)) { - FURI_LOG_E(TAG, "Rewind error"); - return false; - } - - if(!furi_string_cmp_str(preset->protocol, "RAW")) { - subghz_protocol_raw_gen_fff_data(fff_data, path); - // repeat - if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &preset->repeat, 1)) { - FURI_LOG_E(TAG, "Unable to insert or update Repeat"); - break; - } - - } else { - stream_copy_full( - flipper_format_get_raw_stream(fff_file), flipper_format_get_raw_stream(fff_data)); - // repeat - if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &preset->repeat, 1)) { - FURI_LOG_E(TAG, "Unable to insert or update Repeat"); - break; - } - } - - if(!flipper_format_rewind(fff_file)) { - FURI_LOG_E(TAG, "Rewind error"); - return false; - } - - preset->decoder = subghz_receiver_search_decoder_base_by_name( - receiver, furi_string_get_cstr(preset->protocol)); - if(preset->decoder) { - SubGhzProtocolStatus status = - subghz_protocol_decoder_base_deserialize(preset->decoder, fff_data); - if(status != SubGhzProtocolStatusOk) { - FURI_LOG_E(TAG, "Protocol deserialize failed, status = %d", status); - break; - } - } else { - FURI_LOG_E(TAG, "Protocol %s not found", furi_string_get_cstr(temp_str)); - } - - res = true; - } while(0); - - furi_string_free(temp_str); - - return res; -} - -// method modified from subghz_i.c -// https://github.com/flipperdevices/flipperzero-firmware/blob/b0daa601ad5b87427a45f9089c8b403a01f72c2a/applications/subghz/subghz_i.c#L417-L456 -bool subghz_remote_save_protocol_to_file(FlipperFormat* fff_file, const char* dev_file_name) { - furi_assert(fff_file); - furi_assert(dev_file_name); - - Storage* storage = furi_record_open(RECORD_STORAGE); - Stream* flipper_format_stream = flipper_format_get_raw_stream(fff_file); - - bool saved = false; - FuriString* file_dir; - file_dir = furi_string_alloc(); - - path_extract_dirname(dev_file_name, file_dir); - do { - if(!storage_simply_mkdir(storage, furi_string_get_cstr(file_dir))) { - FURI_LOG_E(TAG, "(save) Cannot mkdir"); - break; - } - - if(!storage_simply_remove(storage, dev_file_name)) { - FURI_LOG_E(TAG, "(save) Cannot remove"); - break; - } - - stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); - stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); - - saved = true; - //FURI_LOG_D(TAG, "(save) OK Save"); - } while(0); - furi_string_free(file_dir); - furi_record_close(RECORD_STORAGE); - return saved; +static void subghz_remote_app_tick_event_callback(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + scene_manager_handle_tick_event(app->scene_manager); } -void subghz_remote_tx_stop(SubGHzRemote* app) { - if(app->processing == 0) { - return; - } - - if(!furi_string_cmp_str(app->txpreset->protocol, "RAW")) { - while(!furi_hal_subghz_is_async_tx_complete()) { - furi_delay_ms(15); - } - } +SubGhzRemoteApp* subghz_remote_app_alloc() { + SubGhzRemoteApp* app = malloc(sizeof(SubGhzRemoteApp)); - //Stop TX - furi_hal_subghz_stop_async_tx(); - //FURI_LOG_I(TAG, "TX Done!"); - subghz_transmitter_stop(app->tx_transmitter); - - //FURI_LOG_D(TAG, "Checking if protocol is dynamic"); - const SubGhzProtocolRegistry* protocol_registry_items = - subghz_environment_get_protocol_registry(app->environment); - const SubGhzProtocol* proto = subghz_protocol_registry_get_by_name( - protocol_registry_items, furi_string_get_cstr(app->txpreset->protocol)); - //FURI_LOG_D(TAG, "Protocol-TYPE %d", proto->type); - - if(proto && proto->type == SubGhzProtocolTypeDynamic) { - //FURI_LOG_D(TAG, "Protocol is dynamic. Saving key"); - // Remove repeat if it was present - flipper_format_delete_key(app->tx_fff_data, "Repeat"); - - subghz_remote_save_protocol_to_file(app->tx_fff_data, app->tx_file_path); - - keeloq_reset_mfname(); - keeloq_reset_kl_type(); - keeloq_reset_original_btn(); - subghz_custom_btns_reset(); - star_line_reset_mfname(); - star_line_reset_kl_type(); - } - - subghz_transmitter_free(app->tx_transmitter); - furi_hal_subghz_idle(); - - notification_message(app->notification, &sequence_blink_stop); - - subghz_remote_preset_free(app->txpreset); - flipper_format_free(app->tx_fff_data); - subghz_remote_end_send(app); -} - -static bool subghz_remote_send_sub(SubGHzRemote* app, FlipperFormat* fff_data) { - // - bool res = false; - do { - if(!furi_hal_subghz_is_tx_allowed(app->txpreset->frequency)) { - FURI_LOG_E( - TAG, - "In your settings, only reception on this frequency (%lu) is allowed,\r\n" - "the actual operation of the subghz remote app is not possible\r\n ", - app->txpreset->frequency); - app->tx_not_allowed = true; - subghz_remote_end_send(app); - break; - } else { - app->tx_not_allowed = false; - } - - app->tx_transmitter = subghz_transmitter_alloc_init( - app->environment, furi_string_get_cstr(app->txpreset->protocol)); - if(!app->tx_transmitter) { - break; - } - - if(subghz_transmitter_deserialize(app->tx_transmitter, fff_data) != - SubGhzProtocolStatusOk) { - FURI_LOG_E(TAG, "Deserialize error!"); - break; - } - - furi_hal_subghz_reset(); - furi_hal_subghz_idle(); - furi_hal_subghz_load_custom_preset(app->txpreset->data); - furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); - - furi_hal_subghz_idle(); - - furi_hal_subghz_set_frequency_and_path(app->txpreset->frequency); - furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - - if(!furi_hal_subghz_tx()) { - FURI_LOG_E(TAG, "Sending not allowed"); - break; - } - - //FURI_LOG_I(TAG, "Sending..."); - notification_message(app->notification, &sequence_blink_start_magenta); - - furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->tx_transmitter); - - res = true; - } while(0); - - return res; -} - -static void subghz_remote_send_signal(SubGHzRemote* app, Storage* storage, const char* path) { - //FURI_LOG_D(TAG, "Sending: %s", path); - - app->tx_file_path = path; - - app->tx_fff_data = flipper_format_string_alloc(); - - app->txpreset = subghz_remote_preset_alloc(); - - // load settings/stream from .sub file - FlipperFormat* fff_file = flipper_format_file_alloc(storage); - bool open_ok = false; - do { - if(!flipper_format_file_open_existing(fff_file, path)) { - FURI_LOG_E(TAG, "Could not open file %s", path); - break; - } - if(!subghz_remote_key_load( - app->txpreset, - fff_file, - app->tx_fff_data, - app->setting, - app->subghz_receiver, - path)) { - FURI_LOG_E(TAG, "Could not load key"); - break; - } - open_ok = true; - } while(0); - flipper_format_free(fff_file); - if(!open_ok) { - FURI_LOG_E(TAG, "Could not load file!"); - return; + // Enable power for External CC1101 if it is connected + furi_hal_subghz_enable_ext_power(); + // Auto switch to internal radio if external radio is not available + furi_delay_ms(15); + if(!furi_hal_subghz_check_radio()) { + furi_hal_subghz_select_radio_type(SubGhzRadioInternal); + furi_hal_subghz_init_radio_type(SubGhzRadioInternal); } - subghz_remote_send_sub(app, app->tx_fff_data); -} - -static void subghz_remote_process_signal(SubGHzRemote* app, FuriString* signal) { - view_port_update(app->view_port); - - //FURI_LOG_D(TAG, "signal = %s", furi_string_get_cstr(signal)); - - if(strlen(furi_string_get_cstr(signal)) > 12) { - Storage* storage = furi_record_open(RECORD_STORAGE); - subghz_remote_send_signal(app, storage, furi_string_get_cstr(signal)); - furi_record_close(RECORD_STORAGE); - } else if(strlen(furi_string_get_cstr(signal)) < 10) { - subghz_remote_end_send(app); - } -} + furi_hal_power_suppress_charge_enter(); -static void render_callback(Canvas* canvas, void* ctx) { - SubGHzRemote* app = ctx; - furi_check(furi_mutex_acquire(app->model_mutex, FuriWaitForever) == FuriStatusOk); + app->file_path = furi_string_alloc(); + furi_string_set(app->file_path, STORAGE_APP_DATA_PATH_PREFIX); - //setup different canvas settings - if(app->file_result == 1) { - //if map has no valid filenames defined - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 62, 5, AlignCenter, AlignTop, "Config is incorrect."); - canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 62, 30, AlignCenter, AlignTop, "Please configure map."); - canvas_draw_str_aligned(canvas, 62, 60, AlignCenter, AlignBottom, "Press Back to Exit."); - } else if(app->file_result == 3) { - //if map has no valid filenames defined - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 62, 5, AlignCenter, AlignTop, "Checking config."); - canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 62, 30, AlignCenter, AlignTop, "If app is stuck..."); - canvas_draw_str_aligned(canvas, 62, 60, AlignCenter, AlignBottom, "Press Back to Exit."); - } else if(app->tx_not_allowed) { - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 62, 5, AlignCenter, AlignTop, "Transmission is blocked."); - canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 62, 15, AlignCenter, AlignTop, "Frequency is outside of"); - canvas_draw_str_aligned(canvas, 62, 25, AlignCenter, AlignTop, "default range."); - canvas_draw_str_aligned(canvas, 62, 35, AlignCenter, AlignTop, "Check docs."); - canvas_draw_str_aligned(canvas, 62, 60, AlignCenter, AlignBottom, "Press Back to Exit."); - } else { - //map found, draw all the things - canvas_clear(canvas); + // GUI + app->gui = furi_record_open(RECORD_GUI); - //canvas_set_font(canvas, FontPrimary); - //canvas_draw_str(canvas, 0, 10, "U: "); - //canvas_draw_str(canvas, 0, 20, "L: "); - //canvas_draw_str(canvas, 0, 30, "R: "); - //canvas_draw_str(canvas, 0, 40, "D: "); - //canvas_draw_str(canvas, 0, 50, "Ok: "); + // View Dispatcher + app->view_dispatcher = view_dispatcher_alloc(); + app->scene_manager = scene_manager_alloc(&subrem_scene_handlers, app); + view_dispatcher_enable_queue(app->view_dispatcher); - //PNGs are located in assets/icons/SubGHzRemote before compilation + view_dispatcher_set_event_callback_context(app->view_dispatcher, app); + view_dispatcher_set_custom_event_callback( + app->view_dispatcher, subghz_remote_app_custom_event_callback); + view_dispatcher_set_navigation_event_callback( + app->view_dispatcher, subghz_remote_app_back_event_callback); + view_dispatcher_set_tick_event_callback( + app->view_dispatcher, subghz_remote_app_tick_event_callback, 100); - //Icons for Labels - //canvas_draw_icon(canvas, 0, 0, &I_SubGHzRemote_LeftAlignedButtons_9x64); - canvas_draw_icon(canvas, 1, 5, &I_ButtonUp_7x4); - canvas_draw_icon(canvas, 1, 15, &I_ButtonDown_7x4); - canvas_draw_icon(canvas, 2, 23, &I_ButtonLeft_4x7); - canvas_draw_icon(canvas, 2, 33, &I_ButtonRight_4x7); - canvas_draw_icon(canvas, 0, 42, &I_Ok_btn_9x9); - canvas_draw_icon(canvas, 0, 53, &I_back_10px); + view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); - //Labels - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 10, 10, app->up_label); - canvas_draw_str(canvas, 10, 20, app->down_label); - canvas_draw_str(canvas, 10, 30, app->left_label); - canvas_draw_str(canvas, 10, 40, app->right_label); - canvas_draw_str(canvas, 10, 50, app->ok_label); + // Open Notification record + app->notifications = furi_record_open(RECORD_NOTIFICATION); - canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Press=Exit."); + // SubMenu + app->submenu = submenu_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, SubRemViewSubmenu, submenu_get_view(app->submenu)); - //Status text and indicator - canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, app->send_status); + //Dialog + app->dialogs = furi_record_open(RECORD_DIALOGS); - switch(app->send_status_c) { - case 0: - canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); - break; - case 1: - canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); - canvas_draw_icon(canvas, 116, 17, &I_Pin_arrow_up_7x9); - break; - case 2: - canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); - canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180); - break; - case 3: - canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); - canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); - break; - case 4: - canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); - canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); - break; - case 5: - canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); - canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7); - break; - } + // Remote view + app->subrem_remote_view = subrem_view_remote_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, + SubRemViewIDRemote, + subrem_view_remote_get_view(app->subrem_remote_view)); - //Repeat indicator - //canvas_draw_str_aligned(canvas, 125, 40, AlignRight, AlignBottom, "Repeat:"); - //canvas_draw_icon(canvas, 115, 39, &I_SubGHzRemote_Repeat_12x14); - //canvas_draw_str_aligned(canvas, 125, 62, AlignRight, AlignBottom, int_to_char(app->repeat)); + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + app->subs_preset[i] = subrem_sub_file_preset_alloc(); } - furi_mutex_release(app->model_mutex); -} - -static void input_callback(InputEvent* input_event, void* ctx) { - SubGHzRemote* app = ctx; - furi_message_queue_put(app->input_queue, input_event, 0); -} - -void subghz_remote_subghz_alloc(SubGHzRemote* app) { - // load subghz presets app->setting = subghz_setting_alloc(); subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user")); - // load mfcodes app->environment = subghz_environment_alloc(); + subghz_environment_load_keystore(app->environment, EXT_PATH("subghz/assets/keeloq_mfcodes")); subghz_environment_load_keystore( app->environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user")); subghz_environment_set_came_atomo_rainbow_table_file_name( app->environment, EXT_PATH("subghz/assets/came_atomo")); - subghz_environment_set_nice_flor_s_rainbow_table_file_name( - app->environment, EXT_PATH("subghz/assets/nice_flor_s")); subghz_environment_set_alutech_at_4n_rainbow_table_file_name( app->environment, EXT_PATH("subghz/assets/alutech_at_4n")); + subghz_environment_set_nice_flor_s_rainbow_table_file_name( + app->environment, EXT_PATH("subghz/assets/nice_flor_s")); subghz_environment_set_protocol_registry(app->environment, (void*)&subghz_protocol_registry); - app->subghz_receiver = subghz_receiver_alloc_init(app->environment); -} + app->receiver = subghz_receiver_alloc_init(app->environment); -SubGHzRemote* subghz_remote_alloc(void) { - SubGHzRemote* app = malloc(sizeof(SubGHzRemote)); + app->tx_running = false; - // Enable power for External CC1101 if it is connected - furi_hal_subghz_enable_ext_power(); - // Auto switch to internal radio if external radio is not available - furi_delay_ms(15); - if(!furi_hal_subghz_check_radio()) { - furi_hal_subghz_select_radio_type(SubGhzRadioInternal); - furi_hal_subghz_init_radio_type(SubGhzRadioInternal); - } - - furi_hal_power_suppress_charge_enter(); - - app->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal); - - app->input_queue = furi_message_queue_alloc(32, sizeof(InputEvent)); - - app->view_port = view_port_alloc(); - view_port_draw_callback_set(app->view_port, render_callback, app); - view_port_input_callback_set(app->view_port, input_callback, app); - - // Open GUI and register view_port - app->gui = furi_record_open(RECORD_GUI); - gui_add_view_port(app->gui, app->view_port, GuiLayerFullscreen); - - app->notification = furi_record_open(RECORD_NOTIFICATION); + scene_manager_next_scene(app->scene_manager, SubRemSceneStart); return app; } -void subghz_remote_free(SubGHzRemote* app, bool with_subghz) { +void subghz_remote_app_free(SubGhzRemoteApp* app) { + furi_assert(app); + furi_hal_power_suppress_charge_exit(); // Disable power for External CC1101 if it was enabled and module is connected @@ -798,304 +112,47 @@ void subghz_remote_free(SubGHzRemote* app, bool with_subghz) { // Reinit SPI handles for internal radio / nfc furi_hal_subghz_init_radio_type(SubGhzRadioInternal); - furi_string_free(app->up_file); - furi_string_free(app->down_file); - furi_string_free(app->left_file); - furi_string_free(app->right_file); - furi_string_free(app->ok_file); - - furi_string_free(app->file_path); - furi_string_free(app->signal); + // Submenu + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewSubmenu); + submenu_free(app->submenu); - gui_remove_view_port(app->gui, app->view_port); - furi_record_close(RECORD_GUI); - view_port_free(app->view_port); - app->gui = NULL; + //Dialog + furi_record_close(RECORD_DIALOGS); - furi_message_queue_free(app->input_queue); + // Remote view + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDRemote); + subrem_view_remote_free(app->subrem_remote_view); - furi_mutex_free(app->model_mutex); + subghz_receiver_free(app->receiver); + subghz_environment_free(app->environment); + subghz_setting_free(app->setting); - if(with_subghz) { - furi_hal_subghz_sleep(); - subghz_setting_free(app->setting); - subghz_receiver_free(app->subghz_receiver); - subghz_environment_free(app->environment); + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + subrem_sub_file_preset_free(app->subs_preset[i]); } + // Notifications furi_record_close(RECORD_NOTIFICATION); - app->notification = NULL; + app->notifications = NULL; + + // Close records + furi_record_close(RECORD_GUI); + + // Path strings + furi_string_free(app->file_path); free(app); } int32_t subghz_remote_app(void* p) { UNUSED(p); - SubGHzRemote* app = subghz_remote_alloc(); - - app->file_path = furi_string_alloc(); - app->signal = furi_string_alloc(); - - //setup variables before population - app->up_file = furi_string_alloc(); - app->down_file = furi_string_alloc(); - app->left_file = furi_string_alloc(); - app->right_file = furi_string_alloc(); - app->ok_file = furi_string_alloc(); - - app->file_result = 3; - - Storage* storage = furi_record_open(RECORD_STORAGE); - storage_common_migrate(storage, EXT_PATH("unirf"), SUBREMOTEMAP_FOLDER); - - if(!storage_simply_mkdir(storage, SUBREMOTEMAP_FOLDER)) { - FURI_LOG_E(TAG, "Could not create folder %s", SUBREMOTEMAP_FOLDER); - } - furi_record_close(RECORD_STORAGE); - - furi_string_set(app->file_path, SUBREMOTEMAP_FOLDER); + SubGhzRemoteApp* subghz_remote_app = subghz_remote_app_alloc(); - DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS); + furi_string_set(subghz_remote_app->file_path, SUBREM_APP_FOLDER); - DialogsFileBrowserOptions browser_options; - dialog_file_browser_set_basic_options(&browser_options, SUBREMOTEMAP_EXTENSION, &I_sub1_10px); - browser_options.base_path = SUBREMOTEMAP_FOLDER; - - bool res = dialog_file_browser_show(dialogs, app->file_path, app->file_path, &browser_options); - - furi_record_close(RECORD_DIALOGS); - if(!res) { - FURI_LOG_E(TAG, "No file selected"); - subghz_remote_free(app, false); - return 255; - } else { - //check map and population variables - subghz_remote_cfg_set_check(app, app->file_path); - } - - // init subghz stuff - subghz_remote_subghz_alloc(app); - - bool exit_loop = false; - - if(app->file_result == 2) { - //FURI_LOG_D( - //TAG, - //"U: %s - D: %s - L: %s - R: %s - O: %s ", - //furi_string_get_cstr(app->up_file), - //furi_string_get_cstr(app->down_file), - //furi_string_get_cstr(app->left_file), - //furi_string_get_cstr(app->right_file), - //furi_string_get_cstr(app->ok_file)); - - //variables to control multiple button presses and status updates - app->send_status = "Idle"; - app->send_status_c = 0; - app->processing = 0; - //app->repeat = 1; - app->button = 0; - - //refresh screen to update variables before processing main screen or error screens - furi_mutex_release(app->model_mutex); - view_port_update(app->view_port); - - //input detect loop start - InputEvent input; - while(1) { - furi_check( - furi_message_queue_get(app->input_queue, &input, FuriWaitForever) == FuriStatusOk); - //FURI_LOG_D( - //TAG, - //"key: %s type: %s", - //input_get_key_name(input.key), - //input_get_type_name(input.type)); - - switch(input.key) { - case InputKeyUp: - if(input.type == InputTypePress) { - if(app->up_enabled) { - if(app->processing == 0) { - furi_string_reset(app->signal); - furi_string_set(app->signal, app->up_file); - app->button = 1; - app->processing = 1; - } - } - } - if(input.type == InputTypeRelease) { - if(app->up_enabled) { - subghz_remote_tx_stop(app); - } - } - break; - - case InputKeyDown: - if(input.type == InputTypePress) { - if(app->down_enabled) { - if(app->processing == 0) { - furi_string_reset(app->signal); - furi_string_set(app->signal, app->down_file); - app->button = 2; - app->processing = 1; - } - } - } - if(input.type == InputTypeRelease) { - if(app->down_enabled) { - subghz_remote_tx_stop(app); - } - } - break; - - case InputKeyRight: - if(input.type == InputTypePress) { - if(app->right_enabled) { - if(app->processing == 0) { - furi_string_reset(app->signal); - furi_string_set(app->signal, app->right_file); - app->button = 3; - app->processing = 1; - } - } - } - if(input.type == InputTypeRelease) { - if(app->right_enabled) { - subghz_remote_tx_stop(app); - } - } - break; - - case InputKeyLeft: - if(input.type == InputTypePress) { - if(app->left_enabled) { - if(app->processing == 0) { - furi_string_reset(app->signal); - furi_string_set(app->signal, app->left_file); - app->button = 4; - app->processing = 1; - } - } - } - if(input.type == InputTypeRelease) { - if(app->left_enabled) { - subghz_remote_tx_stop(app); - } - } - break; - - case InputKeyOk: - if(input.type == InputTypePress) { - if(app->ok_enabled) { - if(app->processing == 0) { - furi_string_reset(app->signal); - furi_string_set(app->signal, app->ok_file); - app->button = 5; - app->processing = 1; - } - } - } - if(input.type == InputTypeRelease) { - if(app->ok_enabled) { - subghz_remote_tx_stop(app); - } - } - break; - - case InputKeyBack: - subghz_remote_tx_stop(app); - exit_loop = true; - break; - default: - break; - } - - if(app->processing == 0) { - //FURI_LOG_D(TAG, "processing 0"); - app->send_status = "Idle"; - app->send_status_c = 0; - app->button = 0; - } else if(app->processing == 1) { - //FURI_LOG_D(TAG, "processing 1"); - - app->send_status = "Send"; - - switch(app->button) { - case 1: - app->send_status_c = 1; - break; - case 2: - app->send_status_c = 2; - break; - case 3: - app->send_status_c = 3; - break; - case 4: - app->send_status_c = 4; - break; - case 5: - app->send_status_c = 5; - break; - } - - app->processing = 2; - - subghz_remote_process_signal(app, app->signal); - } - - if(exit_loop == true) { - furi_mutex_release(app->model_mutex); - break; - } - - furi_mutex_release(app->model_mutex); - view_port_update(app->view_port); - } - } else if(app->file_result == 1 || app->file_result == 3) { - //refresh screen to update variables before processing main screen or error screens - view_port_update(app->view_port); - - InputEvent input; - while(1) { - furi_check( - furi_message_queue_get(app->input_queue, &input, FuriWaitForever) == FuriStatusOk); - //FURI_LOG_D( - //TAG, - //"key: %s type: %s", - //input_get_key_name(input.key), - //input_get_type_name(input.type)); - - switch(input.key) { - case InputKeyRight: - break; - case InputKeyLeft: - break; - case InputKeyUp: - break; - case InputKeyDown: - break; - case InputKeyOk: - break; - case InputKeyBack: - exit_loop = true; - break; - default: - break; - } - - if(exit_loop == true) { - furi_mutex_release(app->model_mutex); - break; - } - - furi_mutex_release(app->model_mutex); - view_port_update(app->view_port); - } - } else { - furi_mutex_release(app->model_mutex); - } + view_dispatcher_run(subghz_remote_app->view_dispatcher); - // remove & free all stuff created by app - subghz_remote_free(app, true); + subghz_remote_app_free(subghz_remote_app); return 0; } diff --git a/applications/main/subghz_remote/subghz_remote_app_i.c b/applications/main/subghz_remote/subghz_remote_app_i.c new file mode 100644 index 0000000000..cde4292a43 --- /dev/null +++ b/applications/main/subghz_remote/subghz_remote_app_i.c @@ -0,0 +1,449 @@ +#include "subghz_remote_app_i.h" +#include +#include + +#include + +// #include +// #include + +#include + +#define TAG "SubGhzRemote" + +static const char* map_file_labels[SubRemSubKeyNameMaxCount][2] = { + [SubRemSubKeyNameUp] = {"UP", "ULABEL"}, + [SubRemSubKeyNameDown] = {"DOWN", "DLABEL"}, + [SubRemSubKeyNameLeft] = {"LEFT", "LLABEL"}, + [SubRemSubKeyNameRight] = {"RIGHT", "RLABEL"}, + [SubRemSubKeyNameOk] = {"OK", "OKLABEL"}, +}; + +static bool + subrem_set_preset_data(SubGhzSetting* setting, FreqPreset* freq_preset, const char* preset) { + const char* preset_name = ""; + if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) { + preset_name = "AM270"; + } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) { + preset_name = "AM650"; + } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) { + preset_name = "FM238"; + } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) { + preset_name = "FM476"; + } else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) { + // preset_name = "CUSTOM"; + return false; + } else { + FURI_LOG_E(TAG, "Unknown preset"); + return false; + } + size_t preset_index = subghz_setting_get_inx_preset_by_name(setting, preset_name); + freq_preset->data = subghz_setting_get_preset_data(setting, preset_index); + return true; +} + +SubRemSubFilePreset* subrem_sub_file_preset_alloc() { + SubRemSubFilePreset* sub_preset = malloc(sizeof(SubRemSubFilePreset)); + + sub_preset->fff_data = flipper_format_string_alloc(); + sub_preset->file_path = furi_string_alloc(); + sub_preset->protocaol_name = furi_string_alloc(); + sub_preset->label = furi_string_alloc_set_str("N/A"); + + sub_preset->type = SubGhzProtocolTypeUnknown; + + return sub_preset; +} + +void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { + furi_assert(sub_preset); + + furi_string_free(sub_preset->label); + furi_string_free(sub_preset->protocaol_name); + furi_string_free(sub_preset->file_path); + flipper_format_free(sub_preset->fff_data); + + free(sub_preset); +} + +static void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { + furi_assert(sub_preset); + + furi_string_set_str(sub_preset->label, "N/A"); + furi_string_reset(sub_preset->protocaol_name); + furi_string_reset(sub_preset->file_path); + + Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); + stream_clean(fff_data_stream); + + sub_preset->type = SubGhzProtocolTypeUnknown; +} + +void subrem_map_preset_reset(SubGhzRemoteApp* app) { + furi_assert(app); + + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + subrem_sub_file_preset_reset(app->subs_preset[i]); + } +} + +static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { + furi_assert(app); + bool ret = false; + SubRemSubFilePreset* sub_preset; + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + sub_preset = app->subs_preset[i]; + if(!flipper_format_read_string( + fff_data_file, map_file_labels[i][0], sub_preset->file_path)) { +#if FURI_DEBUG + FURI_LOG_W(TAG, "No file patch for %s", map_file_labels[i][0]); +#endif + sub_preset->type = SubGhzProtocolTypeUnknown; + } else if(!flipper_format_rewind(fff_data_file)) { + // Rewind error + } else if(!flipper_format_read_string( + fff_data_file, map_file_labels[i][1], sub_preset->label)) { +#if FURI_DEBUG + FURI_LOG_W(TAG, "No Label for %s", map_file_labels[i][0]); +#endif + // TODO: Standart name or part of name + furi_string_set_str(sub_preset->label, "N/A"); + } else { + FURI_LOG_I( + TAG, + "%-5s: %s %s", + map_file_labels[i][0], + furi_string_get_cstr(sub_preset->label), + furi_string_get_cstr(sub_preset->file_path)); + ret = true; + } + flipper_format_rewind(fff_data_file); + } + return ret; +} + +bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { + furi_assert(flipper_format); + furi_assert(dev_file_name); + + Storage* storage = furi_record_open(RECORD_STORAGE); + Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); + + bool saved = false; + FuriString* file_dir = furi_string_alloc(); + + path_extract_dirname(dev_file_name, file_dir); + do { + //removing additional fields + flipper_format_delete_key(flipper_format, "Repeat"); + //flipper_format_delete_key(flipper_format, "Manufacture"); + + if(!storage_simply_remove(storage, dev_file_name)) { + break; + } + //ToDo check Write + stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); + stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); + + saved = true; + } while(0); + furi_string_free(file_dir); + furi_record_close(RECORD_STORAGE); + return saved; +} + +bool subrem_tx_start_sub( + SubGhzRemoteApp* app, + SubRemSubFilePreset* sub_preset, + SubGhzProtocolEncoderRAWCallbackEnd callback) { + furi_assert(app); + furi_assert(sub_preset); + bool ret = false; + + subrem_tx_stop_sub(app, true); + + if(sub_preset->type == SubGhzProtocolTypeUnknown) { + return false; + } + + FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); + + subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); + keeloq_reset_original_btn(); + subghz_custom_btns_reset(); + + do { + flipper_format_rewind(sub_preset->fff_data); // + + app->transmitter = subghz_transmitter_alloc_init( + app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); + + if(app->transmitter) { + if(subghz_transmitter_deserialize(app->transmitter, sub_preset->fff_data) != + SubGhzProtocolStatusOk) { + FURI_LOG_E(TAG, "Deserialize error!"); + break; + } + furi_hal_subghz_reset(); + furi_hal_subghz_idle(); + furi_hal_subghz_load_custom_preset(sub_preset->freq_preset.data); + furi_hal_gpio_init( + furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); + + furi_hal_subghz_idle(); + + furi_hal_subghz_set_frequency_and_path(sub_preset->freq_preset.frequency); + furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); + furi_hal_gpio_init( + furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); + + if(!furi_hal_subghz_tx()) { + FURI_LOG_E(TAG, "Sending not allowed"); + break; + } + + if(sub_preset->type == SubGhzProtocolTypeRAW) { + subghz_protocol_raw_file_encoder_worker_set_callback_end( + (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( + app->transmitter), + callback, + app); + } + + furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); + + ret = true; + } + } while(false); + + app->tx_running = ret; + + return ret; +} + +static void subghz_tx_stop(SubGhzRemoteApp* app) { + furi_assert(app); + + //Stop TX + furi_hal_subghz_stop_async_tx(); + + subghz_transmitter_stop(app->transmitter); + subghz_transmitter_free(app->transmitter); + furi_hal_subghz_idle(); +} + +bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { + furi_assert(app); + SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; + + if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) { + // SubRemSubKeyTypeRawKey)) { + if(app->tx_running) { + subghz_tx_stop(app); + + if(sub_preset->type == SubGhzProtocolTypeDynamic) { + subrem_save_protocol_to_file( + sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); + + keeloq_reset_mfname(); + keeloq_reset_kl_type(); + keeloq_reset_original_btn(); + subghz_custom_btns_reset(); + star_line_reset_mfname(); + star_line_reset_kl_type(); + } + + app->tx_running = false; + return true; + } + } + + return false; +} + +static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { + furi_assert(app); + FuriString* temp_str = furi_string_alloc(); + uint32_t temp_data32; + bool ret = false; + bool sub_preset_loaded = false; + SubRemSubFilePreset* sub_preset; + + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + sub_preset = app->subs_preset[i]; + sub_preset_loaded = false; + if(furi_string_empty(sub_preset->file_path)) { + // FURI_LOG_I(TAG, "Empty file path"); + continue; + } + do { + if(!flipper_format_file_open_existing( + fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { + FURI_LOG_W(TAG, "Error open file %s", furi_string_get_cstr(sub_preset->file_path)); + break; + } + + if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) { + FURI_LOG_E(TAG, "Missing or incorrect header"); + break; + } + + if(((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) || + (!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) && + temp_data32 == SUBGHZ_KEY_FILE_VERSION) { + } else { + FURI_LOG_E(TAG, "Type or version mismatch"); + break; + } + + //Load frequency + if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { + FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); + sub_preset->freq_preset.frequency = + subghz_setting_get_default_frequency(app->setting); + } else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { + FURI_LOG_E(TAG, "This frequency can only be used for RX"); + break; + } else { + sub_preset->freq_preset.frequency = temp_data32; + } + + //Load preset + if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { + FURI_LOG_E(TAG, "Missing Preset"); + break; + } + + if(!subrem_set_preset_data( + app->setting, &sub_preset->freq_preset, furi_string_get_cstr(temp_str))) { + FURI_LOG_E(TAG, "Cannot load preset."); + break; + } + + //Load protocol + if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { + FURI_LOG_E(TAG, "Missing Protocol"); + break; + } + + FlipperFormat* fff_data = sub_preset->fff_data; + if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) { + //if RAW + subghz_protocol_raw_gen_fff_data( + fff_data, furi_string_get_cstr(sub_preset->file_path)); + } else { + stream_copy_full( + flipper_format_get_raw_stream(fff_data_file), + flipper_format_get_raw_stream(fff_data)); + } + + const SubGhzProtocolRegistry* protocol_registry_items = + subghz_environment_get_protocol_registry(app->environment); + + const SubGhzProtocol* protocol = subghz_protocol_registry_get_by_name( + protocol_registry_items, furi_string_get_cstr(temp_str)); + + if(!protocol) { + FURI_LOG_E(TAG, "Protocol not found"); + break; + } else if(protocol->flag & SubGhzProtocolFlag_Send) { + if((protocol->type == SubGhzProtocolTypeStatic) || + (protocol->type == SubGhzProtocolTypeDynamic) || + // (protocol->type == SubGhzProtocolTypeBinRAW) || // TODO: BINRAW + (protocol->type == SubGhzProtocolTypeRAW)) { + sub_preset->type = protocol->type; + } else { + FURI_LOG_E(TAG, "Unsuported Protocol"); + break; + } + + furi_string_set(sub_preset->protocaol_name, temp_str); + } else { + FURI_LOG_E(TAG, "Protocol does not support transmission"); + } + + sub_preset_loaded = true; + ret |= true; +#if FURI_DEBUG + FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); +#endif + } while(false); + + // TODO: + // Load file state logic + // Label depending on the state + + if(!sub_preset_loaded) { + furi_string_set_str(sub_preset->label, "N/A"); + } + + flipper_format_file_close(fff_data_file); + } + furi_string_free(temp_str); + + return ret; +} + +bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { + furi_assert(app); + furi_assert(file_path); +#if FURI_DEBUG + FURI_LOG_I(TAG, "Load Map File Start"); +#endif + Storage* storage = furi_record_open(RECORD_STORAGE); + FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); + bool ret = false; +#if FURI_DEBUG + FURI_LOG_I(TAG, "Open Map File.."); +#endif + subrem_map_preset_reset(app); + + if(!flipper_format_file_open_existing(fff_data_file, file_path)) { + FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); + } else { + if(!subrem_map_preset_load(app, fff_data_file)) { + FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); + // ret = // error for popup + } else if( + (flipper_format_file_close(fff_data_file)) && + (subrem_map_preset_check(app, fff_data_file))) { + FURI_LOG_I(TAG, "Load Map File Seccesful"); + ret = true; + } + } + + // TODO: Popup for error or return error type + if(!ret) { + FURI_LOG_E(TAG, "Broken Map File"); + } + + flipper_format_file_close(fff_data_file); + flipper_format_free(fff_data_file); + + furi_record_close(RECORD_STORAGE); + + return ret; +} + +SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) { + furi_assert(app); + + FuriString* file_path = furi_string_alloc(); + SubRemLoadMapState ret = SubRemLoadMapStateBack; + + DialogsFileBrowserOptions browser_options; + dialog_file_browser_set_basic_options(&browser_options, SUBREM_APP_EXTENSION, &I_sub1_10px); + browser_options.base_path = SUBREM_APP_FOLDER; + + // Input events and views are managed by file_select + if(!dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options)) { + } else if(subrem_map_file_load(app, furi_string_get_cstr(app->file_path))) { + ret = SubRemLoadMapStateOK; + } else { + ret = SubRemLoadMapStateError; + } + + furi_string_free(file_path); + + return ret; +} diff --git a/applications/main/subghz_remote/subghz_remote_app_i.h b/applications/main/subghz_remote/subghz_remote_app_i.h new file mode 100644 index 0000000000..98cb4ac48f --- /dev/null +++ b/applications/main/subghz_remote/subghz_remote_app_i.h @@ -0,0 +1,84 @@ +#pragma once + +#include "helpers/subrem_types.h" +#include + +#include "views/remote.h" + +#include "scenes/subrem_scene.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#define SUBREM_APP_FOLDER ANY_PATH("subghz_remote") +#define SUBREM_MAX_LEN_NAME 64 + +typedef struct { + uint32_t frequency; + uint8_t* data; +} FreqPreset; + +// Sub File preset +typedef struct { + FlipperFormat* fff_data; + FreqPreset freq_preset; + FuriString* file_path; + FuriString* protocaol_name; + FuriString* label; + SubGhzProtocolType type; +} SubRemSubFilePreset; + +SubRemSubFilePreset* subrem_sub_file_preset_alloc(); + +void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset); + +typedef struct { + Gui* gui; + ViewDispatcher* view_dispatcher; + SceneManager* scene_manager; + NotificationApp* notifications; + DialogsApp* dialogs; + Submenu* submenu; + FuriString* file_path; + char file_name_tmp[SUBREM_MAX_LEN_NAME]; + + SubRemViewRemote* subrem_remote_view; + + SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; + + SubGhzSetting* setting; + SubGhzEnvironment* environment; + SubGhzReceiver* receiver; + SubGhzTransmitter* transmitter; + + bool tx_running; + + uint8_t chusen_sub; + + // TODO: LoadFileError +} SubGhzRemoteApp; + +SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app); + +bool subrem_tx_start_sub( + SubGhzRemoteApp* app, + SubRemSubFilePreset* sub_preset, + SubGhzProtocolEncoderRAWCallbackEnd callback); + +bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced); \ No newline at end of file diff --git a/applications/main/subghz_remote/views/remote.c b/applications/main/subghz_remote/views/remote.c new file mode 100644 index 0000000000..85c63568ea --- /dev/null +++ b/applications/main/subghz_remote/views/remote.c @@ -0,0 +1,302 @@ +#include "remote.h" +#include "../subghz_remote_app_i.h" + +#include +#include + +#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 16 + +struct SubRemViewRemote { + View* view; + SubRemViewRemoteCallback callback; + void* context; +}; + +// TODO: model +typedef struct { + // FuriString* up_label; + // FuriString* down_label; + // FuriString* left_label; + // FuriString* right_label; + // FuriString* ok_label; + + char* up_label; + char* down_label; + char* left_label; + char* right_label; + char* ok_label; + + SubRemViewRemoteState state; + + uint8_t pressed_btn; +} SubRemViewRemoteModel; + +void subrem_view_remote_set_callback( + SubRemViewRemote* subrem_view_remote, + SubRemViewRemoteCallback callback, + void* context) { + furi_assert(subrem_view_remote); + + subrem_view_remote->callback = callback; + subrem_view_remote->context = context; +} + +void subrem_view_remote_add_data_to_show( + SubRemViewRemote* subrem_view_remote, + const char* up_label, + const char* down_label, + const char* left_label, + const char* right_label, + const char* ok_label) { + furi_assert(subrem_view_remote); + + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { + strncpy(model->up_label, up_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->down_label, down_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->left_label, left_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->right_label, right_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->ok_label, ok_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + + // furi_string_set(model->up_label, up_label); + // furi_string_set(model->down_label, down_label); + // furi_string_set(model->left_label, left_label); + // furi_string_set(model->right_label, right_label); + // furi_string_set(model->ok_label, ok_label); + }, + true); +} + +void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn) { + furi_assert(subrem_view_remote); + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = presed_btn; }, + true); +} + +void subrem_view_remote_set_state( + SubRemViewRemote* subrem_view_remote, + SubRemViewRemoteState state) { + furi_assert(subrem_view_remote); + with_view_model( + subrem_view_remote->view, SubRemViewRemoteModel * model, { model->state = state; }, true); +} + +void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { + canvas_clear(canvas); + canvas_set_color(canvas, ColorBlack); + + canvas_clear(canvas); + + //Icons for Labels + //canvas_draw_icon(canvas, 0, 0, &I_SubGHzRemote_LeftAlignedButtons_9x64); + canvas_draw_icon(canvas, 1, 5, &I_ButtonUp_7x4); + canvas_draw_icon(canvas, 1, 15, &I_ButtonDown_7x4); + canvas_draw_icon(canvas, 2, 23, &I_ButtonLeft_4x7); + canvas_draw_icon(canvas, 2, 33, &I_ButtonRight_4x7); + canvas_draw_icon(canvas, 0, 42, &I_Ok_btn_9x9); + canvas_draw_icon(canvas, 0, 53, &I_back_10px); + + //Labels + canvas_set_font(canvas, FontSecondary); + canvas_draw_str(canvas, 10, 10, model->up_label); + canvas_draw_str(canvas, 10, 20, model->down_label); + canvas_draw_str(canvas, 10, 30, model->left_label); + canvas_draw_str(canvas, 10, 40, model->right_label); + canvas_draw_str(canvas, 10, 50, model->ok_label); + + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + + canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Hold=Exit."); + + //Status text and indicator + canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); + + if(model->state == SubRemViewRemoteStateIdle) { + canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Idle"); + } else { + switch(model->state) { + case SubRemViewRemoteStateSending: + canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Send"); + break; + case SubRemViewRemoteStateLoading: + canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Load"); + break; + default: +#if FURI_DEBUG + canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Wrong_state"); +#endif + break; + } + + switch(model->pressed_btn) { + case SubRemSubKeyNameUp: + canvas_draw_icon(canvas, 116, 17, &I_Pin_arrow_up_7x9); + break; + case SubRemSubKeyNameDown: + canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180); + break; + case SubRemSubKeyNameLeft: + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); + break; + case SubRemSubKeyNameRight: + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); + break; + case SubRemSubKeyNameOk: + canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7); + break; + } + } + //Repeat indicator + //canvas_draw_str_aligned(canvas, 125, 40, AlignRight, AlignBottom, "Repeat:"); + //canvas_draw_icon(canvas, 115, 39, &I_SubGHzRemote_Repeat_12x14); + //canvas_draw_str_aligned(canvas, 125, 62, AlignRight, AlignBottom, int_to_char(app->repeat)); +} + +bool subrem_view_remote_input(InputEvent* event, void* context) { + furi_assert(context); + SubRemViewRemote* subrem_view_remote = context; + + if(event->key == InputKeyBack && event->type == InputTypeLong) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { + strcpy(model->up_label, "N/A"); + strcpy(model->down_label, "N/A"); + strcpy(model->left_label, "N/A"); + strcpy(model->right_label, "N/A"); + strcpy(model->ok_label, "N/A"); + }, + false); + subrem_view_remote->callback(SubRemCustomEventViewRemoteBack, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyBack && event->type == InputTypeShort) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = 0; }, + true); + subrem_view_remote->callback( + SubRemCustomEventViewRemoteForcedStop, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyBack) { + return true; + } + // BACK button processing end + + if(event->key == InputKeyUp && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyDown && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartDOWN, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyLeft && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartLEFT, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyRight && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartRIGHT, subrem_view_remote->context); + return true; + } else if(event->key == InputKeyOk && event->type == InputTypePress) { + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartOK, subrem_view_remote->context); + return true; + } else if(event->type == InputTypeRelease) { + subrem_view_remote->callback(SubRemCustomEventViewRemoteStop, subrem_view_remote->context); + return true; + } + + return true; +} + +void subrem_view_remote_enter(void* context) { + furi_assert(context); +} + +void subrem_view_remote_exit(void* context) { + furi_assert(context); +} + +SubRemViewRemote* subrem_view_remote_alloc() { + SubRemViewRemote* subrem_view_remote = malloc(sizeof(SubRemViewRemote)); + + // View allocation and configuration + subrem_view_remote->view = view_alloc(); + view_allocate_model( + subrem_view_remote->view, ViewModelTypeLocking, sizeof(SubRemViewRemoteModel)); + view_set_context(subrem_view_remote->view, subrem_view_remote); + view_set_draw_callback(subrem_view_remote->view, (ViewDrawCallback)subrem_view_remote_draw); + view_set_input_callback(subrem_view_remote->view, subrem_view_remote_input); + view_set_enter_callback(subrem_view_remote->view, subrem_view_remote_enter); + view_set_exit_callback(subrem_view_remote->view, subrem_view_remote_exit); + + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { + model->state = SubRemViewRemoteStateIdle; + + model->up_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + model->down_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + model->left_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + model->right_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + model->ok_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + + strcpy(model->up_label, "N/A"); + strcpy(model->down_label, "N/A"); + strcpy(model->left_label, "N/A"); + strcpy(model->right_label, "N/A"); + strcpy(model->ok_label, "N/A"); + + // model->up_label = furi_string_alloc_set_str("N/A"); + // model->down_label = furi_string_alloc_set_str("N/A"); + // model->left_label = furi_string_alloc_set_str("N/A"); + // model->right_label = furi_string_alloc_set_str("N/A"); + // model->ok_label = furi_string_alloc_set_str("N/A"); + + model->pressed_btn = 0; + }, + true); + return subrem_view_remote; +} + +void subrem_view_remote_free(SubRemViewRemote* subghz_remote) { + furi_assert(subghz_remote); + + with_view_model( + subghz_remote->view, + SubRemViewRemoteModel * model, + { + free(model->up_label); + free(model->down_label); + free(model->left_label); + free(model->right_label); + free(model->ok_label); + + // furi_string_free(model->up_label); + // furi_string_free(model->down_label); + // furi_string_free(model->left_label); + // furi_string_free(model->right_label); + // furi_string_free(model->ok_label); + }, + true); + view_free(subghz_remote->view); + free(subghz_remote); +} + +View* subrem_view_remote_get_view(SubRemViewRemote* subrem_view_remote) { + furi_assert(subrem_view_remote); + return subrem_view_remote->view; +} \ No newline at end of file diff --git a/applications/main/subghz_remote/views/remote.h b/applications/main/subghz_remote/views/remote.h new file mode 100644 index 0000000000..76121cf8a0 --- /dev/null +++ b/applications/main/subghz_remote/views/remote.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include "../helpers/subrem_custom_event.h" + +typedef enum { + SubRemViewRemoteStateIdle, + SubRemViewRemoteStateLoading, + SubRemViewRemoteStateSending, +} SubRemViewRemoteState; + +typedef struct SubRemViewRemote SubRemViewRemote; + +typedef void (*SubRemViewRemoteCallback)(SubRemCustomEvent event, void* context); + +void subrem_view_remote_set_callback( + SubRemViewRemote* subrem_view_remote, + SubRemViewRemoteCallback callback, + void* context); + +SubRemViewRemote* subrem_view_remote_alloc(); + +void subrem_view_remote_free(SubRemViewRemote* subrem_view_remote); + +View* subrem_view_remote_get_view(SubRemViewRemote* subrem_view_remote); + +void subrem_view_remote_add_data_to_show( + SubRemViewRemote* subrem_view_remote, + const char* up_label, + const char* down_label, + const char* left_label, + const char* right_label, + const char* ok_label); + +void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn); +void subrem_view_remote_set_state( + SubRemViewRemote* subrem_view_remote, + SubRemViewRemoteState state); \ No newline at end of file From 6f9f3e949617d997492ba46c1c6f60a1cefaff30 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Thu, 18 May 2023 15:16:31 +0300 Subject: [PATCH 10/92] minor fixes --- applications/main/subghz_remote/scenes/subrem_scene_remote.c | 1 + applications/main/subghz_remote/subghz_remote_app_i.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/main/subghz_remote/scenes/subrem_scene_remote.c b/applications/main/subghz_remote/scenes/subrem_scene_remote.c index d543ca999f..c245832336 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_remote.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_remote.c @@ -93,6 +93,7 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { notification_message(app->notifications, &sequence_blink_start_magenta); } else { subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + notification_message(app->notifications, &sequence_blink_stop); } return true; } else if(event.event == SubRemCustomEventViewRemoteForcedStop) { diff --git a/applications/main/subghz_remote/subghz_remote_app_i.c b/applications/main/subghz_remote/subghz_remote_app_i.c index cde4292a43..9b0f77d17c 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.c +++ b/applications/main/subghz_remote/subghz_remote_app_i.c @@ -106,8 +106,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data #if FURI_DEBUG FURI_LOG_W(TAG, "No Label for %s", map_file_labels[i][0]); #endif - // TODO: Standart name or part of name - furi_string_set_str(sub_preset->label, "N/A"); + path_extract_filename(sub_preset->file_path, sub_preset->label, true); } else { FURI_LOG_I( TAG, From 6f205edd9a6392b1a58155bc4fcab71eb4246076 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Thu, 18 May 2023 19:20:34 +0300 Subject: [PATCH 11/92] minor fixes --- applications/main/subghz_remote/subghz_remote_app.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index de80c9cdd2..0b3f645ab8 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -35,7 +35,7 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { furi_hal_power_suppress_charge_enter(); app->file_path = furi_string_alloc(); - furi_string_set(app->file_path, STORAGE_APP_DATA_PATH_PREFIX); + furi_string_set(app->file_path, SUBREM_APP_FOLDER); // GUI app->gui = furi_record_open(RECORD_GUI); @@ -97,7 +97,11 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { app->tx_running = false; +#ifdef SUBREM_LIGHT + scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile); +#else scene_manager_next_scene(app->scene_manager, SubRemSceneStart); +#endif return app; } From 99dde674cabb5fb7447e48579d680a02d47c667d Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 19 May 2023 03:31:46 +0300 Subject: [PATCH 12/92] small changes --- applications/main/subghz/application.fam | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/main/subghz/application.fam b/applications/main/subghz/application.fam index 6cd28bd858..60cf0c0b7b 100644 --- a/applications/main/subghz/application.fam +++ b/applications/main/subghz/application.fam @@ -31,6 +31,6 @@ App( appid="subghz_load_dangerous_settings", apptype=FlipperAppType.STARTUP, entry_point="subghz_dangerous_freq", - requires=["subghz"], - order=41, + requires=["storage", "subghz"], + order=500, ) From a7ee5fea93ad424c159b9a9a242a13d6b79f5c8f Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 19 May 2023 04:33:14 +0300 Subject: [PATCH 13/92] Name changer as service + extra checks --- applications/services/application.fam | 1 + applications/services/desktop/desktop.c | 23 ---------- .../services/namechanger/application.fam | 8 ++++ .../services/namechanger/namechange.c | 46 +++++++++++++++++++ lib/toolbox/namechanger.c | 14 ++++++ 5 files changed, 69 insertions(+), 23 deletions(-) create mode 100644 applications/services/namechanger/application.fam create mode 100644 applications/services/namechanger/namechange.c diff --git a/applications/services/application.fam b/applications/services/application.fam index aec49b2312..afa69301d2 100644 --- a/applications/services/application.fam +++ b/applications/services/application.fam @@ -9,5 +9,6 @@ App( "desktop", "loader", "power", + "namechange_srv", ], ) diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 25e2017c2f..77999dfcc0 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -9,9 +9,6 @@ #include #include -#include -#include - #include "animations/animation_manager.h" #include "desktop/scenes/desktop_scene.h" #include "desktop/scenes/desktop_scene_i.h" @@ -429,26 +426,6 @@ int32_t desktop_srv(void* p) { scene_manager_next_scene(desktop->scene_manager, DesktopSceneFault); } - // I added some very bydlo kod here, and thrown some delays to make it worse, pls don't look at it, it will make you cry from laugh - if(furi_hal_rtc_get_boot_mode() == FuriHalRtcBootModeNormal) { - if(NameChanger_Init()) { - Cli* cli = furi_record_open(RECORD_CLI); - cli_session_close(cli); - furi_delay_ms(2); - cli_session_open(cli, &cli_vcp); - furi_record_close(RECORD_CLI); - - furi_delay_ms(3); - Bt* bt = furi_record_open(RECORD_BT); - if(!bt_set_profile(bt, BtProfileSerial)) { - FURI_LOG_D(TAG, "Failed to touch bluetooth to name change"); - } - furi_record_close(RECORD_BT); - bt = NULL; - furi_delay_ms(3); - } - } - view_dispatcher_run(desktop->view_dispatcher); desktop_free(desktop); diff --git a/applications/services/namechanger/application.fam b/applications/services/namechanger/application.fam new file mode 100644 index 0000000000..a4bc23938a --- /dev/null +++ b/applications/services/namechanger/application.fam @@ -0,0 +1,8 @@ +App( + appid="namechange_srv", + apptype=FlipperAppType.STARTUP, + entry_point="namechange_on_system_start", + requires=["storage", "cli", "bt"], + conflicts=["updater"], + order=600, +) \ No newline at end of file diff --git a/applications/services/namechanger/namechange.c b/applications/services/namechanger/namechange.c new file mode 100644 index 0000000000..22cb0d9de5 --- /dev/null +++ b/applications/services/namechanger/namechange.c @@ -0,0 +1,46 @@ +#include +#include +#include +#include + +#include +#include + +int32_t namechange_on_system_start(void* p) { + UNUSED(p); + if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) { + return 0; + } + + // Wait for all required services to start and create their records + uint8_t timeout = 0; + while(!furi_record_exists(RECORD_CLI) || !furi_record_exists(RECORD_BT) || + !furi_record_exists(RECORD_STORAGE)) { + timeout++; + if(timeout > 250) { + return 0; + } + furi_delay_ms(5); + } + + // Hehe bad code now here, bad bad bad, very bad, bad example, dont take it, make it better + + if(NameChanger_Init()) { + Cli* cli = furi_record_open(RECORD_CLI); + cli_session_close(cli); + furi_delay_ms(2); // why i added delays here + cli_session_open(cli, &cli_vcp); + furi_record_close(RECORD_CLI); + + furi_delay_ms(3); + Bt* bt = furi_record_open(RECORD_BT); + if(!bt_set_profile(bt, BtProfileSerial)) { + //FURI_LOG_D(TAG, "Failed to touch bluetooth to name change"); + } + furi_record_close(RECORD_BT); + bt = NULL; + furi_delay_ms(3); + } + + return 0; +} \ No newline at end of file diff --git a/lib/toolbox/namechanger.c b/lib/toolbox/namechanger.c index 33842bcd74..94e08ac13f 100644 --- a/lib/toolbox/namechanger.c +++ b/lib/toolbox/namechanger.c @@ -6,6 +6,20 @@ bool NameChanger_Init() { Storage* storage = furi_record_open(RECORD_STORAGE); + + // Kostil + velosiped = top ficha + uint8_t timeout = 0; + while(timeout < 11) { + if(storage_sd_status(storage) == FSE_OK) break; + furi_delay_ms(250); + timeout++; + /*if(timeout == 10) { + // Failed to init namechanger, SD card not ready + furi_record_close(RECORD_STORAGE); + return false; + }*/ + } + FuriString* str = furi_string_alloc(); FlipperFormat* file = flipper_format_file_alloc(storage); From 324186dad2917372f520fd7e55d499b33d126e89 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 19 May 2023 04:49:29 +0300 Subject: [PATCH 14/92] Add back cnt in debug --- .../scenes/subghz_scene_radio_settings.c | 84 ++++++++++++++----- 1 file changed, 65 insertions(+), 19 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_radio_settings.c b/applications/main/subghz/scenes/subghz_scene_radio_settings.c index 8e8d05019a..b60ea0b2dc 100644 --- a/applications/main/subghz/scenes/subghz_scene_radio_settings.c +++ b/applications/main/subghz/scenes/subghz_scene_radio_settings.c @@ -25,11 +25,14 @@ const char* const debug_pin_text[DEBUG_P_COUNT] = { "17(1W)", }; -#define DEBUG_COUNTER_COUNT 3 +#define DEBUG_COUNTER_COUNT 6 const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = { "+1", "+2", "+3", + "+4", + "+5", + "+10", }; static void subghz_scene_ext_module_changed(VariableItem* item) { @@ -71,6 +74,15 @@ static void subghz_scene_receiver_config_set_debug_counter(VariableItem* item) { case 2: furi_hal_subghz_set_rolling_counter_mult(3); break; + case 3: + furi_hal_subghz_set_rolling_counter_mult(4); + break; + case 4: + furi_hal_subghz_set_rolling_counter_mult(5); + break; + case 5: + furi_hal_subghz_set_rolling_counter_mult(10); + break; default: break; } @@ -140,24 +152,58 @@ void subghz_scene_radio_settings_on_enter(void* context) { variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, timestamp_names_text[value_index]); - item = variable_item_list_add( - subghz->variable_item_list, - "Counter incr.", - DEBUG_COUNTER_COUNT, - subghz_scene_receiver_config_set_debug_counter, - subghz); - switch(furi_hal_subghz_get_rolling_counter_mult()) { - case 1: - value_index = 0; - break; - case 2: - value_index = 1; - break; - case 3: - value_index = 2; - break; - default: - break; + if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) { + item = variable_item_list_add( + subghz->variable_item_list, + "Counter incr.", + DEBUG_COUNTER_COUNT, + subghz_scene_receiver_config_set_debug_counter, + subghz); + switch(furi_hal_subghz_get_rolling_counter_mult()) { + case 1: + value_index = 0; + break; + case 2: + value_index = 1; + break; + case 3: + value_index = 2; + break; + case 4: + value_index = 3; + break; + case 5: + value_index = 4; + break; + case 10: + value_index = 5; + break; + default: + break; + } + } else { + item = variable_item_list_add( + subghz->variable_item_list, + "Counter incr.", + 3, + subghz_scene_receiver_config_set_debug_counter, + subghz); + switch(furi_hal_subghz_get_rolling_counter_mult()) { + case 1: + value_index = 0; + break; + case 2: + value_index = 1; + break; + case 3: + value_index = 2; + break; + default: + // Reset to default value + value_index = 0; + furi_hal_subghz_set_rolling_counter_mult(1); + break; + } } variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, debug_counter_text[value_index]); From 481a8e0f33bb32dfedd8d0650bef1b07189ccd80 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 19 May 2023 04:51:25 +0300 Subject: [PATCH 15/92] Move after nchgr service --- applications/main/subghz/application.fam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/main/subghz/application.fam b/applications/main/subghz/application.fam index 60cf0c0b7b..0b403fedaf 100644 --- a/applications/main/subghz/application.fam +++ b/applications/main/subghz/application.fam @@ -32,5 +32,5 @@ App( apptype=FlipperAppType.STARTUP, entry_point="subghz_dangerous_freq", requires=["storage", "subghz"], - order=500, + order=650, ) From 10d926de0df79fd590d044646a4009075a79bbb6 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 19 May 2023 05:09:14 +0300 Subject: [PATCH 16/92] EXT_PATH only --- applications/main/subghz_remote/subghz_remote_app_i.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/main/subghz_remote/subghz_remote_app_i.h b/applications/main/subghz_remote/subghz_remote_app_i.h index 98cb4ac48f..1cbdbd5cd0 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.h +++ b/applications/main/subghz_remote/subghz_remote_app_i.h @@ -26,7 +26,7 @@ #include #include -#define SUBREM_APP_FOLDER ANY_PATH("subghz_remote") +#define SUBREM_APP_FOLDER EXT_PATH("subghz_remote") #define SUBREM_MAX_LEN_NAME 64 typedef struct { From e7965c6d95ceb465296f53b3a49f146b719d11e5 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 19 May 2023 06:33:15 +0300 Subject: [PATCH 17/92] De-libify name changer --- applications/services/application.fam | 2 +- .../services/namechanger/application.fam | 4 +- .../services/namechanger/namechange.c | 46 ------------------- .../services/namechanger}/namechanger.c | 46 ++++++++++++++++++- .../services/namechanger/namechanger.h | 5 ++ .../desktop_settings/desktop_settings_app.c | 2 +- lib/toolbox/namechanger.h | 18 -------- 7 files changed, 54 insertions(+), 69 deletions(-) delete mode 100644 applications/services/namechanger/namechange.c rename {lib/toolbox => applications/services/namechanger}/namechanger.c (60%) create mode 100644 applications/services/namechanger/namechanger.h delete mode 100644 lib/toolbox/namechanger.h diff --git a/applications/services/application.fam b/applications/services/application.fam index afa69301d2..0b50090966 100644 --- a/applications/services/application.fam +++ b/applications/services/application.fam @@ -9,6 +9,6 @@ App( "desktop", "loader", "power", - "namechange_srv", + "namechanger_srv", ], ) diff --git a/applications/services/namechanger/application.fam b/applications/services/namechanger/application.fam index a4bc23938a..0eaeab9873 100644 --- a/applications/services/namechanger/application.fam +++ b/applications/services/namechanger/application.fam @@ -1,7 +1,7 @@ App( - appid="namechange_srv", + appid="namechanger_srv", apptype=FlipperAppType.STARTUP, - entry_point="namechange_on_system_start", + entry_point="namechanger_on_system_start", requires=["storage", "cli", "bt"], conflicts=["updater"], order=600, diff --git a/applications/services/namechanger/namechange.c b/applications/services/namechanger/namechange.c deleted file mode 100644 index 22cb0d9de5..0000000000 --- a/applications/services/namechanger/namechange.c +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -int32_t namechange_on_system_start(void* p) { - UNUSED(p); - if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) { - return 0; - } - - // Wait for all required services to start and create their records - uint8_t timeout = 0; - while(!furi_record_exists(RECORD_CLI) || !furi_record_exists(RECORD_BT) || - !furi_record_exists(RECORD_STORAGE)) { - timeout++; - if(timeout > 250) { - return 0; - } - furi_delay_ms(5); - } - - // Hehe bad code now here, bad bad bad, very bad, bad example, dont take it, make it better - - if(NameChanger_Init()) { - Cli* cli = furi_record_open(RECORD_CLI); - cli_session_close(cli); - furi_delay_ms(2); // why i added delays here - cli_session_open(cli, &cli_vcp); - furi_record_close(RECORD_CLI); - - furi_delay_ms(3); - Bt* bt = furi_record_open(RECORD_BT); - if(!bt_set_profile(bt, BtProfileSerial)) { - //FURI_LOG_D(TAG, "Failed to touch bluetooth to name change"); - } - furi_record_close(RECORD_BT); - bt = NULL; - furi_delay_ms(3); - } - - return 0; -} \ No newline at end of file diff --git a/lib/toolbox/namechanger.c b/applications/services/namechanger/namechanger.c similarity index 60% rename from lib/toolbox/namechanger.c rename to applications/services/namechanger/namechanger.c index 94e08ac13f..796dd2d3b0 100644 --- a/lib/toolbox/namechanger.c +++ b/applications/services/namechanger/namechanger.c @@ -1,10 +1,15 @@ #include "namechanger.h" +#include #include +#include +#include +#include +#include #include #define TAG "NameChanger" -bool NameChanger_Init() { +static bool namechanger_init() { Storage* storage = furi_record_open(RECORD_STORAGE); // Kostil + velosiped = top ficha @@ -64,4 +69,43 @@ bool NameChanger_Init() { furi_string_free(str); return res; +} + +int32_t namechanger_on_system_start(void* p) { + UNUSED(p); + if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) { + return 0; + } + + // Wait for all required services to start and create their records + uint8_t timeout = 0; + while(!furi_record_exists(RECORD_CLI) || !furi_record_exists(RECORD_BT) || + !furi_record_exists(RECORD_STORAGE)) { + timeout++; + if(timeout > 250) { + return 0; + } + furi_delay_ms(5); + } + + // Hehe bad code now here, bad bad bad, very bad, bad example, dont take it, make it better + + if(namechanger_init()) { + Cli* cli = furi_record_open(RECORD_CLI); + cli_session_close(cli); + furi_delay_ms(2); // why i added delays here + cli_session_open(cli, &cli_vcp); + furi_record_close(RECORD_CLI); + + furi_delay_ms(3); + Bt* bt = furi_record_open(RECORD_BT); + if(!bt_set_profile(bt, BtProfileSerial)) { + //FURI_LOG_D(TAG, "Failed to touch bluetooth to name change"); + } + furi_record_close(RECORD_BT); + bt = NULL; + furi_delay_ms(3); + } + + return 0; } \ No newline at end of file diff --git a/applications/services/namechanger/namechanger.h b/applications/services/namechanger/namechanger.h new file mode 100644 index 0000000000..dac1b7952e --- /dev/null +++ b/applications/services/namechanger/namechanger.h @@ -0,0 +1,5 @@ +#pragma once + +#define NAMECHANGER_HEADER "Flipper Name File" +#define NAMECHANGER_VERSION 1 +#define NAMECHANGER_PATH EXT_PATH("dolphin/name.settings") diff --git a/applications/settings/desktop_settings/desktop_settings_app.c b/applications/settings/desktop_settings/desktop_settings_app.c index 317d576546..7e04271f2b 100644 --- a/applications/settings/desktop_settings/desktop_settings_app.c +++ b/applications/settings/desktop_settings/desktop_settings_app.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include diff --git a/lib/toolbox/namechanger.h b/lib/toolbox/namechanger.h deleted file mode 100644 index bfaadec154..0000000000 --- a/lib/toolbox/namechanger.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#define NAMECHANGER_HEADER "Flipper Name File" -#define NAMECHANGER_VERSION 1 -#define NAMECHANGER_PATH EXT_PATH("dolphin/name.settings") - -#include "stdbool.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Initializes the name changer. (Load name file, apply changes) -bool NameChanger_Init(); - -#ifdef __cplusplus -} -#endif \ No newline at end of file From d062ce73d71789bcf511ebf2a75bf36501d7bf98 Mon Sep 17 00:00:00 2001 From: Max Andreev Date: Fri, 19 May 2023 12:32:30 +0300 Subject: [PATCH 18/92] Add new indexer (#2681) --- .github/workflows/build.yml | 17 +++++------------ .github/workflows/reindex.yml | 3 ++- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8358d1706a..ca603a64a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -123,18 +123,11 @@ jobs: - name: 'Upload artifacts to update server' if: ${{ !github.event.pull_request.head.repo.fork }} run: | - mkdir -p ~/.ssh - ssh-keyscan -p ${{ secrets.RSYNC_DEPLOY_PORT }} -H ${{ secrets.RSYNC_DEPLOY_HOST }} > ~/.ssh/known_hosts - echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key; - chmod 600 ./deploy_key; - rsync -avzP --delete --mkpath \ - -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \ - artifacts/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${BRANCH_NAME}/"; - rm ./deploy_key; - - - name: 'Trigger update server reindex' - if: ${{ !github.event.pull_request.head.repo.fork }} - run: curl -X POST -F 'key=${{ secrets.REINDEX_KEY }}' ${{ secrets.REINDEX_URL }} + FILES=$(for CUR in $(ls artifacts/); do echo "-F files=@artifacts/$CUR"; done) + curl --fail -L -H "Token: ${{ secrets.INDEXER_TOKEN }}" \ + -F "branch=${BRANCH_NAME}" \ + ${FILES[@]} \ + "${{ secrets.INDEXER_URL }}"/firmware/uploadfiles - name: 'Find Previous Comment' if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }} diff --git a/.github/workflows/reindex.yml b/.github/workflows/reindex.yml index ea850e7051..5645f609ba 100644 --- a/.github/workflows/reindex.yml +++ b/.github/workflows/reindex.yml @@ -11,4 +11,5 @@ jobs: steps: - name: Trigger reindex run: | - curl -X POST -F 'key=${{ secrets.REINDEX_KEY }}' ${{ secrets.REINDEX_URL }} + curl --fail -L -H "Token: ${{ secrets.INDEXER_TOKEN }}" \ + "${{ secrets.INDEXER_URL }}"/firmware/reindex From 1d79e149cfb3279c9b27fcc2873c3fba8a928841 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 19 May 2023 12:32:35 +0300 Subject: [PATCH 19/92] subrem fix repeat --- .../main/subghz_remote/subghz_remote_app_i.c | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/applications/main/subghz_remote/subghz_remote_app_i.c b/applications/main/subghz_remote/subghz_remote_app_i.c index 9b0f77d17c..171618a5f8 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.c +++ b/applications/main/subghz_remote/subghz_remote_app_i.c @@ -129,23 +129,31 @@ bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); bool saved = false; + uint32_t repeat = 200; FuriString* file_dir = furi_string_alloc(); path_extract_dirname(dev_file_name, file_dir); do { - //removing additional fields + // removing additional fields flipper_format_delete_key(flipper_format, "Repeat"); - //flipper_format_delete_key(flipper_format, "Manufacture"); + // flipper_format_delete_key(flipper_format, "Manufacture"); if(!storage_simply_remove(storage, dev_file_name)) { break; } + //ToDo check Write stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); + if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + saved = true; } while(0); + furi_string_free(file_dir); furi_record_close(RECORD_STORAGE); return saved; @@ -267,7 +275,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat bool ret = false; bool sub_preset_loaded = false; SubRemSubFilePreset* sub_preset; - + uint32_t repeat = 200; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { sub_preset = app->subs_preset[i]; sub_preset_loaded = false; @@ -275,6 +283,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat // FURI_LOG_I(TAG, "Empty file path"); continue; } + repeat = 200; do { if(!flipper_format_file_open_existing( fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { @@ -361,6 +370,11 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat FURI_LOG_E(TAG, "Protocol does not support transmission"); } + if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + sub_preset_loaded = true; ret |= true; #if FURI_DEBUG From 0b25cc5a5c9777085bc93bddb1d66a29e15a9f44 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 19 May 2023 21:06:03 +0300 Subject: [PATCH 20/92] fap --- .../subghz_remote_new/application.fam | 13 +- .../helpers/subrem_custom_event.h | 6 +- .../subghz_remote_new/helpers/subrem_types.h | 18 +- .../scenes/subrem_scene_openmapfile.c | 21 +- .../scenes/subrem_scene_remote.c | 34 +- .../scenes/subrem_scene_start.c | 1 - .../subghz_remote_new/subghz_remote_app.c | 39 +-- .../subghz_remote_new/subghz_remote_app_i.c | 66 ++-- .../subghz_remote_new/subghz_remote_app_i.h | 23 +- .../external/subghz_remote_new/views/remote.c | 38 +-- .../views/transmitter_old.txt | 317 ------------------ 11 files changed, 92 insertions(+), 484 deletions(-) delete mode 100644 applications/external/subghz_remote_new/views/transmitter_old.txt diff --git a/applications/external/subghz_remote_new/application.fam b/applications/external/subghz_remote_new/application.fam index 389f02b61a..09eb7e64e8 100644 --- a/applications/external/subghz_remote_new/application.fam +++ b/applications/external/subghz_remote_new/application.fam @@ -1,16 +1,19 @@ App( - appid="subghz_remote_new", - name="SubRem new", - apptype=FlipperAppType.EXTERNAL, + appid="subrem_remote_fap", + name="Sub-GHz Remote", + apptype=FlipperAppType.APP, entry_point="subghz_remote_app", + cdefines=[ + "APP_SUBGHZREMOTE", + "SUBREM_LIGHT", + ], requires=[ "gui", "dialogs", ], - cdefines=["SUBREM_LIGHT"], icon="A_SubGHzRemote_14", stack_size=4 * 1024, - order=12, + order=50, fap_category="Debug", fap_icon_assets="icons", ) \ No newline at end of file diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h index 90d60f0269..46ab8ad547 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h +++ b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h @@ -1,13 +1,9 @@ #pragma once typedef enum { - // SubRemCustomEventManagerNoSet = 0, - // SubRemCustomEventManagerSet, - // SubRemCustomEventManagerSetRAW, - //SubmenuIndex SubmenuIndexSubRemOpenMapFile, - SubmenuIndexSubRemRemoteView, // TODO: temp debug + SubmenuIndexSubRemRemoteView, SubmenuIndexSubRemAbout, //SubRemCustomEvent diff --git a/applications/external/subghz_remote_new/helpers/subrem_types.h b/applications/external/subghz_remote_new/helpers/subrem_types.h index 0bf31e6a4a..1b99aac6d2 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_types.h +++ b/applications/external/subghz_remote_new/helpers/subrem_types.h @@ -3,6 +3,7 @@ #include #include +// TODO: File version/type logic // #define SUBREM_APP_APP_FILE_VERSION 1 // #define SUBREM_APP_APP_FILE_TYPE "Flipper SubRem Map file" #define SUBREM_APP_EXTENSION ".txt" @@ -25,16 +26,7 @@ typedef enum { } SubRemViewID; typedef enum { - // Loadin State - SubRemSubKeyTypeNoData = 0, - // SubRemSubKeyTypeHaveFileName, - - // Key Type - SubRemSubKeyTypeStaticKey = 100, - SubRemSubKeyTypeDynamicKey, - SubRemSubKeyTypeRawKey, -} SubRemSubKeyType; // TODO: depricated - -// typedef enum { -// -// } SubRemLoadMapState; \ No newline at end of file + SubRemLoadMapStateBack = 0, + SubRemLoadMapStateError, + SubRemLoadMapStateOK, +} SubRemLoadMapState; \ No newline at end of file diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c index cb93134ab6..3391845e12 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c @@ -2,15 +2,12 @@ void subrem_scene_openmapfile_on_enter(void* context) { SubGhzRemoteApp* app = context; + SubRemLoadMapState load_state = subrem_load_from_file(app); - if(subrem_load_from_file(app)) { - scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); - } else { - // TODO: Map Preset Reset - - // #if SUBREM_LIGHT - // dialog_message_show_storage_error(app->dialogs, "Can't load\nMap file"); - // #else + if(load_state == SubRemLoadMapStateError) { +#ifdef SUBREM_LIGHT + dialog_message_show_storage_error(app->dialogs, "Can't load\nMap file"); +#else DialogMessage* message = dialog_message_alloc(); dialog_message_set_header(message, "Map File Error", 64, 8, AlignCenter, AlignCenter); @@ -19,8 +16,12 @@ void subrem_scene_openmapfile_on_enter(void* context) { dialog_message_show(app->dialogs, message); dialog_message_free(message); - // #endif - +#endif + } + if(load_state == SubRemLoadMapStateOK) { + scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); + } else { + // TODO: Map Preset Reset if(!scene_manager_search_and_switch_to_previous_scene( app->scene_manager, SubRemSceneStart)) { scene_manager_stop(app->scene_manager); diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c index a04399cd3f..c245832336 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c @@ -5,12 +5,6 @@ #define TAG "SubRemScenRemote" -// TODO: -// #include -// #include - -// #include - void subrem_scene_remote_callback(SubRemCustomEvent event, void* context) { furi_assert(context); SubGhzRemoteApp* app = context; @@ -59,16 +53,10 @@ static bool subrem_scene_remote_update_data_show(void* context) { void subrem_scene_remote_on_enter(void* context) { SubGhzRemoteApp* app = context; - // TODO: init view data + subrem_scene_remote_update_data_show(app); - if(!subrem_scene_remote_update_data_show(app)) { - // view_dispatcher_send_custom_event( - // app->view_dispatcher, SubGhzCustomEventViewTransmitterError); - } subrem_view_remote_set_callback(app->subrem_remote_view, subrem_scene_remote_callback, app); - // TODO: notifications - // app->state_notifications = SubGhzNotificationStateIDLE; view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDRemote); } @@ -92,10 +80,10 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { event.event == SubRemCustomEventViewRemoteStartRIGHT || event.event == SubRemCustomEventViewRemoteStartOK) { // Start sending sub - subghz_tx_stop_sub(app, true); + subrem_tx_stop_sub(app, true); app->chusen_sub = subrem_scene_remote_event_to_index(event.event); subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateLoading); - if(subghz_tx_start_sub( + if(subrem_tx_start_sub( app, app->subs_preset[app->chusen_sub], subrem_scene_remote_raw_callback_end_tx)) { @@ -105,17 +93,18 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { notification_message(app->notifications, &sequence_blink_start_magenta); } else { subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + notification_message(app->notifications, &sequence_blink_stop); } return true; } else if(event.event == SubRemCustomEventViewRemoteForcedStop) { - subghz_tx_stop_sub(app, true); + subrem_tx_stop_sub(app, true); subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); notification_message(app->notifications, &sequence_blink_stop); return true; } else if(event.event == SubRemCustomEventViewRemoteStop) { - if(subghz_tx_stop_sub(app, false)) { + if(subrem_tx_stop_sub(app, false)) { subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); @@ -132,19 +121,10 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { void subrem_scene_remote_on_exit(void* context) { SubGhzRemoteApp* app = context; - subghz_tx_stop_sub(app, true); + subrem_tx_stop_sub(app, true); subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); notification_message(app->notifications, &sequence_blink_stop); - - // TODO: notifications and reset KL - - // keeloq_reset_mfname(); - // keeloq_reset_kl_type(); - // keeloq_reset_original_btn(); - // subghz_custom_btns_reset(); - // star_line_reset_mfname(); - // star_line_reset_kl_type(); } diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c index 75328ab8a7..962eda54ca 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c @@ -48,7 +48,6 @@ bool subrem_scene_start_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { if(event.event == SubmenuIndexSubRemOpenMapFile) { - //scene_manager_set_scene_state(app->scene_manager, SubRemSceneStart, event.event); scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile); consumed = true; } diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_new/subghz_remote_app.c index ad6fe13fbc..0b3f645ab8 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app.c +++ b/applications/external/subghz_remote_new/subghz_remote_app.c @@ -34,16 +34,8 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { furi_hal_power_suppress_charge_enter(); - // // Enable 5v power, multiple attempts to avoid issues with power chip protection false triggering - // uint8_t attempts = 0; - // while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { - // furi_hal_power_enable_otg(); - // furi_delay_ms(10); - // } - app->file_path = furi_string_alloc(); - furi_string_set(app->file_path, STORAGE_APP_DATA_PATH_PREFIX); - //app->error = SubGhzRemoteErrorNoError; + furi_string_set(app->file_path, SUBREM_APP_FOLDER); // GUI app->gui = furi_record_open(RECORD_GUI); @@ -71,19 +63,6 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { view_dispatcher_add_view( app->view_dispatcher, SubRemViewSubmenu, submenu_get_view(app->submenu)); - // Widget - app->widget = widget_alloc(); - view_dispatcher_add_view(app->view_dispatcher, SubRemViewWidget, widget_get_view(app->widget)); - - // Text Input - app->text_input = text_input_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, SubRemViewTextInput, text_input_get_view(app->text_input)); - - // Popup - app->popup = popup_alloc(); - view_dispatcher_add_view(app->view_dispatcher, SubRemViewPopup, popup_get_view(app->popup)); - //Dialog app->dialogs = furi_record_open(RECORD_DIALOGS); @@ -118,7 +97,11 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { app->tx_running = false; +#ifdef SUBREM_LIGHT + scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile); +#else scene_manager_next_scene(app->scene_manager, SubRemSceneStart); +#endif return app; } @@ -137,18 +120,6 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { view_dispatcher_remove_view(app->view_dispatcher, SubRemViewSubmenu); submenu_free(app->submenu); - // Widget - view_dispatcher_remove_view(app->view_dispatcher, SubRemViewWidget); - widget_free(app->widget); - - // TextInput - view_dispatcher_remove_view(app->view_dispatcher, SubRemViewTextInput); - text_input_free(app->text_input); - - // Popup - view_dispatcher_remove_view(app->view_dispatcher, SubRemViewPopup); - popup_free(app->popup); - //Dialog furi_record_close(RECORD_DIALOGS); diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index da3f317174..2437dd2baa 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -2,9 +2,13 @@ #include #include -#include #include +// #include +// #include + +#include + #define TAG "SubGhzRemote" static const char* map_file_labels[SubRemSubKeyNameMaxCount][2] = { @@ -91,7 +95,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data sub_preset = app->subs_preset[i]; if(!flipper_format_read_string( fff_data_file, map_file_labels[i][0], sub_preset->file_path)) { -#if FURO_LOG +#if FURI_DEBUG FURI_LOG_W(TAG, "No file patch for %s", map_file_labels[i][0]); #endif sub_preset->type = SubGhzProtocolTypeUnknown; @@ -99,11 +103,10 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data // Rewind error } else if(!flipper_format_read_string( fff_data_file, map_file_labels[i][1], sub_preset->label)) { -#if FURO_LOG +#if FURI_DEBUG FURI_LOG_W(TAG, "No Label for %s", map_file_labels[i][0]); #endif - furi_string_set_str(sub_preset->label, - "N/A"); // TODO: Standart name or part of name + path_extract_filename(sub_preset->file_path, sub_preset->label, true); } else { FURI_LOG_I( TAG, @@ -118,8 +121,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data return ret; } -bool subghz_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { - // furi_assert(subghz); +bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { furi_assert(flipper_format); furi_assert(dev_file_name); @@ -135,12 +137,6 @@ bool subghz_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev flipper_format_delete_key(flipper_format, "Repeat"); //flipper_format_delete_key(flipper_format, "Manufacture"); - // Create subghz folder directory if necessary - // if(!storage_simply_mkdir(storage, furi_string_get_cstr(file_dir))) { - // dialog_message_show_storage_error(subghz->dialogs, "Cannot create\nfolder"); - // break; - // } - if(!storage_simply_remove(storage, dev_file_name)) { break; } @@ -155,7 +151,7 @@ bool subghz_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev return saved; } -bool subghz_tx_start_sub( +bool subrem_tx_start_sub( SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset, SubGhzProtocolEncoderRAWCallbackEnd callback) { @@ -163,7 +159,7 @@ bool subghz_tx_start_sub( furi_assert(sub_preset); bool ret = false; - subghz_tx_stop_sub(app, true); + subrem_tx_stop_sub(app, true); if(sub_preset->type == SubGhzProtocolTypeUnknown) { return false; @@ -171,8 +167,12 @@ bool subghz_tx_start_sub( FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); + // subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); + // keeloq_reset_original_btn(); + // subghz_custom_btns_reset(); + do { - flipper_format_rewind(sub_preset->fff_data); // FIXME: + flipper_format_rewind(sub_preset->fff_data); // app->transmitter = subghz_transmitter_alloc_init( app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); @@ -215,7 +215,7 @@ bool subghz_tx_start_sub( } } while(false); - app->tx_running = ret; // TODO: + app->tx_running = ret; return ret; } @@ -231,7 +231,7 @@ static void subghz_tx_stop(SubGhzRemoteApp* app) { furi_hal_subghz_idle(); } -bool subghz_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { +bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { furi_assert(app); SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; @@ -241,8 +241,15 @@ bool subghz_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { subghz_tx_stop(app); if(sub_preset->type == SubGhzProtocolTypeDynamic) { - subghz_save_protocol_to_file( + subrem_save_protocol_to_file( sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); + + // keeloq_reset_mfname(); + // keeloq_reset_kl_type(); + // keeloq_reset_original_btn(); + // subghz_custom_btns_reset(); + // star_line_reset_mfname(); + // star_line_reset_kl_type(); } app->tx_running = false; @@ -251,10 +258,6 @@ bool subghz_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { } return false; - - // SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; - - // TODO: need saving logic } static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { @@ -408,7 +411,7 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { } } - // TODO: Pop for error or return error type + // TODO: Popup for error or return error type if(!ret) { FURI_LOG_E(TAG, "Broken Map File"); } @@ -421,24 +424,25 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { return ret; } -bool subrem_load_from_file(SubGhzRemoteApp* app) { +SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) { furi_assert(app); FuriString* file_path = furi_string_alloc(); + SubRemLoadMapState ret = SubRemLoadMapStateBack; DialogsFileBrowserOptions browser_options; dialog_file_browser_set_basic_options(&browser_options, SUBREM_APP_EXTENSION, &I_sub1_10px); browser_options.base_path = SUBREM_APP_FOLDER; // Input events and views are managed by file_select - bool res = - dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options); - - if(res) { - res = subrem_map_file_load(app, furi_string_get_cstr(app->file_path)); + if(!dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options)) { + } else if(subrem_map_file_load(app, furi_string_get_cstr(app->file_path))) { + ret = SubRemLoadMapStateOK; + } else { + ret = SubRemLoadMapStateError; } furi_string_free(file_path); - return res; + return ret; } diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index 8941f1401f..0cff3898ac 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -1,7 +1,9 @@ #pragma once #include "helpers/subrem_types.h" -#include // TODO: +#include + +// #include #include "views/remote.h" @@ -18,16 +20,16 @@ #include #include +#include + #include #include #include #include -#include // FIXME: - -#define SUBREM_APP_FOLDER ANY_PATH("subghz_remote") -#define SUBGHZ_REMOTE_MAX_LEN_NAME 64 +#define SUBREM_APP_FOLDER EXT_PATH("subghz_remote") +#define SUBREM_MAX_LEN_NAME 64 typedef struct { uint32_t frequency; @@ -54,12 +56,9 @@ typedef struct { SceneManager* scene_manager; NotificationApp* notifications; DialogsApp* dialogs; - Popup* popup; Submenu* submenu; - Widget* widget; - TextInput* text_input; FuriString* file_path; - char file_name_tmp[SUBGHZ_REMOTE_MAX_LEN_NAME]; + char file_name_tmp[SUBREM_MAX_LEN_NAME]; SubRemViewRemote* subrem_remote_view; @@ -77,11 +76,11 @@ typedef struct { // TODO: LoadFileError } SubGhzRemoteApp; -bool subrem_load_from_file(SubGhzRemoteApp* app); +SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app); -bool subghz_tx_start_sub( +bool subrem_tx_start_sub( SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset, SubGhzProtocolEncoderRAWCallbackEnd callback); -bool subghz_tx_stop_sub(SubGhzRemoteApp* app, bool forced); \ No newline at end of file +bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced); \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/remote.c b/applications/external/subghz_remote_new/views/remote.c index c631c76cc2..85c63568ea 100644 --- a/applications/external/subghz_remote_new/views/remote.c +++ b/applications/external/subghz_remote_new/views/remote.c @@ -29,9 +29,6 @@ typedef struct { SubRemViewRemoteState state; uint8_t pressed_btn; - // bool show_button; - // FuriString* temp_button_id; - // bool draw_temp_button; } SubRemViewRemoteModel; void subrem_view_remote_set_callback( @@ -93,18 +90,8 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); - //map found, draw all the things canvas_clear(canvas); - //canvas_set_font(canvas, FontPrimary); - //canvas_draw_str(canvas, 0, 10, "U: "); - //canvas_draw_str(canvas, 0, 20, "L: "); - //canvas_draw_str(canvas, 0, 30, "R: "); - //canvas_draw_str(canvas, 0, 40, "D: "); - //canvas_draw_str(canvas, 0, 50, "Ok: "); - - //PNGs are located in assets/icons/SubGHzRemote before compilation - //Icons for Labels //canvas_draw_icon(canvas, 0, 0, &I_SubGHzRemote_LeftAlignedButtons_9x64); canvas_draw_icon(canvas, 1, 5, &I_ButtonUp_7x4); @@ -121,6 +108,7 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_draw_str(canvas, 10, 30, model->left_label); canvas_draw_str(canvas, 10, 40, model->right_label); canvas_draw_str(canvas, 10, 50, model->ok_label); + // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); @@ -130,9 +118,6 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Hold=Exit."); //Status text and indicator - - //canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, model->state); - canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); if(model->state == SubRemViewRemoteStateIdle) { @@ -146,7 +131,9 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Load"); break; default: - canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Idle"); +#if FURI_DEBUG + canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Wrong_state"); +#endif break; } @@ -179,7 +166,6 @@ bool subrem_view_remote_input(InputEvent* event, void* context) { SubRemViewRemote* subrem_view_remote = context; if(event->key == InputKeyBack && event->type == InputTypeLong) { - // TODO: remove reset Debug with_view_model( subrem_view_remote->view, SubRemViewRemoteModel * model, @@ -189,12 +175,6 @@ bool subrem_view_remote_input(InputEvent* event, void* context) { strcpy(model->left_label, "N/A"); strcpy(model->right_label, "N/A"); strcpy(model->ok_label, "N/A"); - - // furi_string_reset(model->up_label); - // furi_string_reset(model->down_label); - // furi_string_reset(model->left_label); - // furi_string_reset(model->right_label); - // furi_string_reset(model->ok_label); }, false); subrem_view_remote->callback(SubRemCustomEventViewRemoteBack, subrem_view_remote->context); @@ -280,11 +260,11 @@ SubRemViewRemote* subrem_view_remote_alloc() { strcpy(model->right_label, "N/A"); strcpy(model->ok_label, "N/A"); - // model->up_label = furi_string_alloc(); - // model->down_label = furi_string_alloc(); - // model->left_label = furi_string_alloc(); - // model->right_label = furi_string_alloc(); - // model->ok_label = furi_string_alloc(); + // model->up_label = furi_string_alloc_set_str("N/A"); + // model->down_label = furi_string_alloc_set_str("N/A"); + // model->left_label = furi_string_alloc_set_str("N/A"); + // model->right_label = furi_string_alloc_set_str("N/A"); + // model->ok_label = furi_string_alloc_set_str("N/A"); model->pressed_btn = 0; }, diff --git a/applications/external/subghz_remote_new/views/transmitter_old.txt b/applications/external/subghz_remote_new/views/transmitter_old.txt deleted file mode 100644 index ea2dc2f627..0000000000 --- a/applications/external/subghz_remote_new/views/transmitter_old.txt +++ /dev/null @@ -1,317 +0,0 @@ -#include "transmitter.h" -#include "../subghz_remote_app_i.h" - -#include -#include - -#include - -struct SubGhzRemoteViewRemote { - View* view; - SubGhzRemoteViewRemoteCallback callback; - void* context; -}; - -typedef struct { - FuriString* frequency_str; - FuriString* preset_str; - FuriString* key_str; - // bool show_button; - // FuriString* temp_button_id; - // bool draw_temp_button; -} SubGhzRemoteViewRemoteModel; - -void subghz_view_transmitter_set_callback( - SubGhzRemoteViewRemote* subghz_transmitter, - SubGhzRemoteViewRemoteCallback callback, - void* context) { - furi_assert(subghz_transmitter); - - subghz_transmitter->callback = callback; - subghz_transmitter->context = context; -} - -void subghz_view_transmitter_add_data_to_show( - SubGhzRemoteViewRemote* subghz_transmitter, - const char* key_str, - const char* frequency_str, - const char* preset_str, - bool show_button) { - furi_assert(subghz_transmitter); - with_view_model( - subghz_transmitter->view, - SubGhzRemoteViewRemoteModel * model, - { - furi_string_set(model->key_str, key_str); - furi_string_set(model->frequency_str, frequency_str); - furi_string_set(model->preset_str, preset_str); - model->show_button = show_button; - }, - true); -} - -static void subghz_view_transmitter_button_right(Canvas* canvas, const char* str) { - const uint8_t button_height = 12; - const uint8_t vertical_offset = 3; - const uint8_t horizontal_offset = 1; - const uint8_t string_width = canvas_string_width(canvas, str); - const Icon* icon = &I_ButtonCenter_7x7; - const uint8_t icon_offset = 3; - const uint8_t icon_width_with_offset = icon_get_width(icon) + icon_offset; - const uint8_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset; - - const uint8_t x = (canvas_width(canvas) - button_width) / 2 + 40; - const uint8_t y = canvas_height(canvas); - - canvas_draw_box(canvas, x, y - button_height, button_width, button_height); - - canvas_draw_line(canvas, x - 1, y, x - 1, y - button_height + 0); - canvas_draw_line(canvas, x - 2, y, x - 2, y - button_height + 1); - canvas_draw_line(canvas, x - 3, y, x - 3, y - button_height + 2); - - canvas_draw_line(canvas, x + button_width + 0, y, x + button_width + 0, y - button_height + 0); - canvas_draw_line(canvas, x + button_width + 1, y, x + button_width + 1, y - button_height + 1); - canvas_draw_line(canvas, x + button_width + 2, y, x + button_width + 2, y - button_height + 2); - - canvas_invert_color(canvas); - canvas_draw_icon( - canvas, - x + horizontal_offset, - y - button_height + vertical_offset - 1, - &I_ButtonCenter_7x7); - canvas_draw_str( - canvas, x + horizontal_offset + icon_width_with_offset, y - vertical_offset, str); - canvas_invert_color(canvas); -} - -void subghz_view_transmitter_draw(Canvas* canvas, SubGhzRemoteViewRemoteModel* model) { - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontSecondary); - elements_multiline_text_aligned( - canvas, 0, 0, AlignLeft, AlignTop, furi_string_get_cstr(model->key_str)); - canvas_draw_str(canvas, 78, 7, furi_string_get_cstr(model->frequency_str)); - canvas_draw_str(canvas, 113, 7, furi_string_get_cstr(model->preset_str)); - - // if(model->draw_temp_button) { - // canvas_set_font(canvas, FontBatteryPercent); - // canvas_draw_str(canvas, 117, 40, furi_string_get_cstr(model->temp_button_id)); - // canvas_set_font(canvas, FontSecondary); - // } - - // if(model->show_button) { - // canvas_draw_str(canvas, 58, 62, furi_hal_subghz_get_radio_type() ? "R: Ext" : "R: Int"); - // subghz_view_transmitter_button_right(canvas, "Send"); - // } -} - -bool subghz_view_transmitter_input(InputEvent* event, void* context) { - furi_assert(context); - SubGhzRemoteViewRemote* subghz_transmitter = context; - bool can_be_sent = false; - - if(event->key == InputKeyBack && event->type == InputTypeShort) { - with_view_model( - subghz_transmitter->view, - SubGhzRemoteViewRemoteModel * model, - { - furi_string_reset(model->frequency_str); - furi_string_reset(model->preset_str); - furi_string_reset(model->key_str); - furi_string_reset(model->temp_button_id); - model->show_button = false; - model->draw_temp_button = false; - }, - false); - return false; - } - - with_view_model( - subghz_transmitter->view, - SubGhzRemoteViewRemoteModel * model, - { - if(model->show_button) { - can_be_sent = true; - } - }, - true); - - if(can_be_sent && event->key == InputKeyOk && event->type == InputTypePress) { - subghz_custom_btn_set(0); - with_view_model( - subghz_transmitter->view, - SubGhzRemoteViewRemoteModel * model, - { - furi_string_reset(model->temp_button_id); - model->draw_temp_button = false; - }, - true); - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); - return true; - } else if(can_be_sent && event->key == InputKeyOk && event->type == InputTypeRelease) { - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); - return true; - } - - // Temp Buttons (UP) - if(can_be_sent && event->key == InputKeyUp && event->type == InputTypePress) { - subghz_custom_btn_set(1); - with_view_model( - subghz_transmitter->view, - SubGhzRemoteViewRemoteModel * model, - { - furi_string_reset(model->temp_button_id); - if(subghz_custom_btn_get_original() != 0) { - if(subghz_custom_btn_get() == 1) { - furi_string_printf( - model->temp_button_id, "%01X", subghz_custom_btn_get_original()); - model->draw_temp_button = true; - } - } - }, - true); - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); - return true; - } else if(can_be_sent && event->key == InputKeyUp && event->type == InputTypeRelease) { - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); - return true; - } - // Down - if(can_be_sent && event->key == InputKeyDown && event->type == InputTypePress) { - subghz_custom_btn_set(2); - with_view_model( - subghz_transmitter->view, - SubGhzRemoteViewRemoteModel * model, - { - furi_string_reset(model->temp_button_id); - if(subghz_custom_btn_get_original() != 0) { - if(subghz_custom_btn_get() == 2) { - furi_string_printf( - model->temp_button_id, "%01X", subghz_custom_btn_get_original()); - model->draw_temp_button = true; - } - } - }, - true); - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); - return true; - } else if(can_be_sent && event->key == InputKeyDown && event->type == InputTypeRelease) { - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); - return true; - } - // Left - if(can_be_sent && event->key == InputKeyLeft && event->type == InputTypePress) { - subghz_custom_btn_set(3); - with_view_model( - subghz_transmitter->view, - SubGhzRemoteViewRemoteModel * model, - { - furi_string_reset(model->temp_button_id); - if(subghz_custom_btn_get_original() != 0) { - if(subghz_custom_btn_get() == 3) { - furi_string_printf( - model->temp_button_id, "%01X", subghz_custom_btn_get_original()); - model->draw_temp_button = true; - } - } - }, - true); - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); - return true; - } else if(can_be_sent && event->key == InputKeyLeft && event->type == InputTypeRelease) { - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); - return true; - } - // Right - if(can_be_sent && event->key == InputKeyRight && event->type == InputTypePress) { - subghz_custom_btn_set(4); - with_view_model( - subghz_transmitter->view, - SubGhzRemoteViewRemoteModel * model, - { - furi_string_reset(model->temp_button_id); - if(subghz_custom_btn_get_original() != 0) { - if(subghz_custom_btn_get() == 4) { - furi_string_printf( - model->temp_button_id, "%01X", subghz_custom_btn_get_original()); - model->draw_temp_button = true; - } - } - }, - true); - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); - return true; - } else if(can_be_sent && event->key == InputKeyRight && event->type == InputTypeRelease) { - subghz_transmitter->callback( - SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); - return true; - } - - return true; -} - -void subghz_view_transmitter_enter(void* context) { - furi_assert(context); -} - -void subghz_view_transmitter_exit(void* context) { - furi_assert(context); -} - -SubGhzRemoteViewRemote* subghz_view_transmitter_alloc() { - SubGhzRemoteViewRemote* subghz_transmitter = malloc(sizeof(SubGhzRemoteViewRemote)); - - // View allocation and configuration - subghz_transmitter->view = view_alloc(); - view_allocate_model( - subghz_transmitter->view, ViewModelTypeLocking, sizeof(SubGhzRemoteViewRemoteModel)); - view_set_context(subghz_transmitter->view, subghz_transmitter); - view_set_draw_callback( - subghz_transmitter->view, (ViewDrawCallback)subghz_view_transmitter_draw); - view_set_input_callback(subghz_transmitter->view, subghz_view_transmitter_input); - view_set_enter_callback(subghz_transmitter->view, subghz_view_transmitter_enter); - view_set_exit_callback(subghz_transmitter->view, subghz_view_transmitter_exit); - - with_view_model( - subghz_transmitter->view, - SubGhzRemoteViewRemoteModel * model, - { - model->frequency_str = furi_string_alloc(); - model->preset_str = furi_string_alloc(); - model->key_str = furi_string_alloc(); - model->temp_button_id = furi_string_alloc(); - }, - true); - return subghz_transmitter; -} - -void subghz_view_transmitter_free(SubGhzRemoteViewRemote* subghz_transmitter) { - furi_assert(subghz_transmitter); - - with_view_model( - subghz_transmitter->view, - SubGhzRemoteViewRemoteModel * model, - { - furi_string_free(model->frequency_str); - furi_string_free(model->preset_str); - furi_string_free(model->key_str); - furi_string_free(model->temp_button_id); - }, - true); - view_free(subghz_transmitter->view); - free(subghz_transmitter); -} - -View* subghz_view_transmitter_get_view(SubGhzRemoteViewRemote* subghz_transmitter) { - furi_assert(subghz_transmitter); - return subghz_transmitter->view; -} From 1f97e9be343724c0100c0e9bdd60461b88913d33 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 19 May 2023 21:21:36 +0300 Subject: [PATCH 21/92] fix repeat --- .../subghz_remote_new/application.fam | 2 +- .../subghz_remote_new/subghz_remote_app_i.c | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/applications/external/subghz_remote_new/application.fam b/applications/external/subghz_remote_new/application.fam index 09eb7e64e8..f2cdd25b07 100644 --- a/applications/external/subghz_remote_new/application.fam +++ b/applications/external/subghz_remote_new/application.fam @@ -1,7 +1,7 @@ App( appid="subrem_remote_fap", name="Sub-GHz Remote", - apptype=FlipperAppType.APP, + apptype=FlipperAppType.EXTERNAL, entry_point="subghz_remote_app", cdefines=[ "APP_SUBGHZREMOTE", diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index 2437dd2baa..18ebb05f6f 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -129,23 +129,31 @@ bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); bool saved = false; + uint32_t repeat = 200; FuriString* file_dir = furi_string_alloc(); path_extract_dirname(dev_file_name, file_dir); do { - //removing additional fields + // removing additional fields flipper_format_delete_key(flipper_format, "Repeat"); - //flipper_format_delete_key(flipper_format, "Manufacture"); + // flipper_format_delete_key(flipper_format, "Manufacture"); if(!storage_simply_remove(storage, dev_file_name)) { break; } + //ToDo check Write stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); + if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + saved = true; } while(0); + furi_string_free(file_dir); furi_record_close(RECORD_STORAGE); return saved; @@ -267,7 +275,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat bool ret = false; bool sub_preset_loaded = false; SubRemSubFilePreset* sub_preset; - + uint32_t repeat = 200; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { sub_preset = app->subs_preset[i]; sub_preset_loaded = false; @@ -275,6 +283,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat // FURI_LOG_I(TAG, "Empty file path"); continue; } + repeat = 200; do { if(!flipper_format_file_open_existing( fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { @@ -361,6 +370,11 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat FURI_LOG_E(TAG, "Protocol does not support transmission"); } + if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + sub_preset_loaded = true; ret |= true; #if FURI_DEBUG From e295c7aac250dda004f4a6f19a2d09232901d715 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 19 May 2023 22:59:43 +0300 Subject: [PATCH 22/92] Load states & fix label length --- .../subghz_remote_new/helpers/subrem_types.h | 15 +++++ .../scenes/subrem_scene_openmapfile.c | 2 +- .../scenes/subrem_scene_start.c | 6 +- .../subghz_remote_new/subghz_remote_app_i.c | 55 ++++++++++++------- .../subghz_remote_new/subghz_remote_app_i.h | 3 +- .../external/subghz_remote_new/views/remote.c | 2 +- 6 files changed, 57 insertions(+), 26 deletions(-) diff --git a/applications/external/subghz_remote_new/helpers/subrem_types.h b/applications/external/subghz_remote_new/helpers/subrem_types.h index 1b99aac6d2..13b42897f6 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_types.h +++ b/applications/external/subghz_remote_new/helpers/subrem_types.h @@ -25,8 +25,23 @@ typedef enum { SubRemViewIDRemote, } SubRemViewID; +typedef enum { + SubRemLoadSubStateNotSet, + SubRemLoadSubStatePreloaded, + SubRemLoadSubStateError, + SubRemLoadSubStateErrorNoFile, + SubRemLoadSubStateErrorFreq, + SubRemLoadSubStateErrorMod, + SubRemLoadSubStateErrorProtocol, + SubRemLoadSubStateOK, +} SubRemLoadSubState; + typedef enum { SubRemLoadMapStateBack = 0, SubRemLoadMapStateError, + SubRemLoadMapStateErrorOpenError, + SubRemLoadMapStateErrorStorage, + SubRemLoadMapStateErrorBrokenFile, + SubRemLoadMapStateNotAllOK, SubRemLoadMapStateOK, } SubRemLoadMapState; \ No newline at end of file diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c index 3391845e12..ea5c14a0a5 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c @@ -18,7 +18,7 @@ void subrem_scene_openmapfile_on_enter(void* context) { dialog_message_free(message); #endif } - if(load_state == SubRemLoadMapStateOK) { + if(load_state == SubRemLoadMapStateOK || load_state == SubRemLoadMapStateNotAllOK) { scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); } else { // TODO: Map Preset Reset diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c index 962eda54ca..a4bfa50475 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c @@ -34,8 +34,10 @@ void subrem_scene_start_on_enter(void* context) { // subrem_scene_start_submenu_callback, // app); - submenu_set_selected_item( - submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); + // TODO: set scene state in subrem alloc + // submenu_set_selected_item( + // submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); + submenu_set_selected_item(submenu, SubmenuIndexSubRemOpenMapFile); view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewSubmenu); } diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index 18ebb05f6f..4f5065b077 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -51,6 +51,7 @@ SubRemSubFilePreset* subrem_sub_file_preset_alloc() { sub_preset->label = furi_string_alloc_set_str("N/A"); sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; return sub_preset; } @@ -77,6 +78,7 @@ static void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { stream_clean(fff_data_stream); sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; } void subrem_map_preset_reset(SubGhzRemoteApp* app) { @@ -108,6 +110,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data #endif path_extract_filename(sub_preset->file_path, sub_preset->label, true); } else { + // Preload seccesful FURI_LOG_I( TAG, "%-5s: %s %s", @@ -115,6 +118,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data furi_string_get_cstr(sub_preset->label), furi_string_get_cstr(sub_preset->file_path)); ret = true; + sub_preset->load_state = SubRemLoadSubStatePreloaded; } flipper_format_rewind(fff_data_file); } @@ -268,21 +272,23 @@ bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { return false; } -static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { +static SubRemLoadMapState + subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); FuriString* temp_str = furi_string_alloc(); uint32_t temp_data32; - bool ret = false; - bool sub_preset_loaded = false; + bool all_loaded = true; + SubRemLoadMapState ret = SubRemLoadMapStateErrorBrokenFile; + SubRemLoadSubState sub_preset_loaded; SubRemSubFilePreset* sub_preset; uint32_t repeat = 200; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { sub_preset = app->subs_preset[i]; - sub_preset_loaded = false; if(furi_string_empty(sub_preset->file_path)) { // FURI_LOG_I(TAG, "Empty file path"); continue; } + sub_preset_loaded = SubRemLoadSubStateErrorNoFile; repeat = 200; do { if(!flipper_format_file_open_existing( @@ -305,6 +311,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat } //Load frequency + sub_preset_loaded = SubRemLoadSubStateErrorFreq; if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); sub_preset->freq_preset.frequency = @@ -317,6 +324,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat } //Load preset + sub_preset_loaded = SubRemLoadSubStateErrorMod; if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { FURI_LOG_E(TAG, "Missing Preset"); break; @@ -329,6 +337,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat } //Load protocol + sub_preset_loaded = SubRemLoadSubStateErrorProtocol; if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { FURI_LOG_E(TAG, "Missing Protocol"); break; @@ -375,8 +384,8 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat break; } - sub_preset_loaded = true; - ret |= true; + sub_preset_loaded = SubRemLoadSubStateOK; + ret = SubRemLoadMapStateNotAllOK; #if FURI_DEBUG FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); #endif @@ -385,9 +394,15 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat // TODO: // Load file state logic // Label depending on the state + // Move to remote scene - if(!sub_preset_loaded) { + if(sub_preset_loaded != SubRemLoadSubStateOK) { furi_string_set_str(sub_preset->label, "N/A"); + all_loaded = false; + } + + if(ret != SubRemLoadMapStateErrorBrokenFile && all_loaded) { + ret = SubRemLoadMapStateOK; } flipper_format_file_close(fff_data_file); @@ -397,7 +412,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat return ret; } -bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { +SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { furi_assert(app); furi_assert(file_path); #if FURI_DEBUG @@ -405,7 +420,7 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { #endif Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); - bool ret = false; + SubRemLoadMapState ret = SubRemLoadMapStateErrorOpenError; #if FURI_DEBUG FURI_LOG_I(TAG, "Open Map File.."); #endif @@ -413,20 +428,23 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { if(!flipper_format_file_open_existing(fff_data_file, file_path)) { FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); + ret = SubRemLoadMapStateErrorOpenError; } else { if(!subrem_map_preset_load(app, fff_data_file)) { FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); // ret = // error for popup - } else if( - (flipper_format_file_close(fff_data_file)) && - (subrem_map_preset_check(app, fff_data_file))) { - FURI_LOG_I(TAG, "Load Map File Seccesful"); - ret = true; + } else if(!flipper_format_file_close(fff_data_file)) { + ret = SubRemLoadMapStateErrorOpenError; + } else { + ret = subrem_map_preset_check(app, fff_data_file); } } - // TODO: Popup for error or return error type - if(!ret) { + if(ret == SubRemLoadMapStateOK) { + FURI_LOG_I(TAG, "Load Map File Seccesful"); + } else if(ret == SubRemLoadMapStateNotAllOK) { + FURI_LOG_I(TAG, "Load Map File Seccesful [Not all files]"); + } else { FURI_LOG_E(TAG, "Broken Map File"); } @@ -434,7 +452,6 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { flipper_format_free(fff_data_file); furi_record_close(RECORD_STORAGE); - return ret; } @@ -450,10 +467,8 @@ SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) { // Input events and views are managed by file_select if(!dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options)) { - } else if(subrem_map_file_load(app, furi_string_get_cstr(app->file_path))) { - ret = SubRemLoadMapStateOK; } else { - ret = SubRemLoadMapStateError; + ret = subrem_map_file_load(app, furi_string_get_cstr(app->file_path)); } furi_string_free(file_path); diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index 0cff3898ac..06abe659cb 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -44,6 +44,7 @@ typedef struct { FuriString* protocaol_name; FuriString* label; SubGhzProtocolType type; + SubRemLoadSubState load_state; } SubRemSubFilePreset; SubRemSubFilePreset* subrem_sub_file_preset_alloc(); @@ -72,8 +73,6 @@ typedef struct { bool tx_running; uint8_t chusen_sub; - - // TODO: LoadFileError } SubGhzRemoteApp; SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app); diff --git a/applications/external/subghz_remote_new/views/remote.c b/applications/external/subghz_remote_new/views/remote.c index 85c63568ea..1f867cd0b6 100644 --- a/applications/external/subghz_remote_new/views/remote.c +++ b/applications/external/subghz_remote_new/views/remote.c @@ -4,7 +4,7 @@ #include #include -#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 16 +#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 12 struct SubRemViewRemote { View* view; From 47f6d787372e577e137f3fd4c645323b436c4b5a Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 19 May 2023 23:21:18 +0300 Subject: [PATCH 23/92] Loading States & fix label length --- .../main/subghz_remote/helpers/subrem_types.h | 15 +++++ .../scenes/subrem_scene_openmapfile.c | 2 +- .../subghz_remote/scenes/subrem_scene_start.c | 6 +- .../main/subghz_remote/subghz_remote_app_i.c | 58 ++++++++++++------- .../main/subghz_remote/subghz_remote_app_i.h | 3 +- .../main/subghz_remote/views/remote.c | 2 +- 6 files changed, 60 insertions(+), 26 deletions(-) diff --git a/applications/main/subghz_remote/helpers/subrem_types.h b/applications/main/subghz_remote/helpers/subrem_types.h index 1b99aac6d2..13b42897f6 100644 --- a/applications/main/subghz_remote/helpers/subrem_types.h +++ b/applications/main/subghz_remote/helpers/subrem_types.h @@ -25,8 +25,23 @@ typedef enum { SubRemViewIDRemote, } SubRemViewID; +typedef enum { + SubRemLoadSubStateNotSet, + SubRemLoadSubStatePreloaded, + SubRemLoadSubStateError, + SubRemLoadSubStateErrorNoFile, + SubRemLoadSubStateErrorFreq, + SubRemLoadSubStateErrorMod, + SubRemLoadSubStateErrorProtocol, + SubRemLoadSubStateOK, +} SubRemLoadSubState; + typedef enum { SubRemLoadMapStateBack = 0, SubRemLoadMapStateError, + SubRemLoadMapStateErrorOpenError, + SubRemLoadMapStateErrorStorage, + SubRemLoadMapStateErrorBrokenFile, + SubRemLoadMapStateNotAllOK, SubRemLoadMapStateOK, } SubRemLoadMapState; \ No newline at end of file diff --git a/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c b/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c index 3391845e12..ea5c14a0a5 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c @@ -18,7 +18,7 @@ void subrem_scene_openmapfile_on_enter(void* context) { dialog_message_free(message); #endif } - if(load_state == SubRemLoadMapStateOK) { + if(load_state == SubRemLoadMapStateOK || load_state == SubRemLoadMapStateNotAllOK) { scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); } else { // TODO: Map Preset Reset diff --git a/applications/main/subghz_remote/scenes/subrem_scene_start.c b/applications/main/subghz_remote/scenes/subrem_scene_start.c index 962eda54ca..a4bfa50475 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_start.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_start.c @@ -34,8 +34,10 @@ void subrem_scene_start_on_enter(void* context) { // subrem_scene_start_submenu_callback, // app); - submenu_set_selected_item( - submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); + // TODO: set scene state in subrem alloc + // submenu_set_selected_item( + // submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); + submenu_set_selected_item(submenu, SubmenuIndexSubRemOpenMapFile); view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewSubmenu); } diff --git a/applications/main/subghz_remote/subghz_remote_app_i.c b/applications/main/subghz_remote/subghz_remote_app_i.c index 171618a5f8..349fb87cdb 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.c +++ b/applications/main/subghz_remote/subghz_remote_app_i.c @@ -51,6 +51,7 @@ SubRemSubFilePreset* subrem_sub_file_preset_alloc() { sub_preset->label = furi_string_alloc_set_str("N/A"); sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; return sub_preset; } @@ -77,6 +78,7 @@ static void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { stream_clean(fff_data_stream); sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; } void subrem_map_preset_reset(SubGhzRemoteApp* app) { @@ -108,6 +110,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data #endif path_extract_filename(sub_preset->file_path, sub_preset->label, true); } else { + // Preload seccesful FURI_LOG_I( TAG, "%-5s: %s %s", @@ -115,6 +118,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data furi_string_get_cstr(sub_preset->label), furi_string_get_cstr(sub_preset->file_path)); ret = true; + sub_preset->load_state = SubRemLoadSubStatePreloaded; } flipper_format_rewind(fff_data_file); } @@ -268,21 +272,25 @@ bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { return false; } -static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { +static SubRemLoadMapState + subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); FuriString* temp_str = furi_string_alloc(); uint32_t temp_data32; - bool ret = false; - bool sub_preset_loaded = false; + bool all_loaded = true; + SubRemLoadMapState ret = SubRemLoadMapStateErrorBrokenFile; + SubRemLoadSubState sub_preset_loaded; SubRemSubFilePreset* sub_preset; uint32_t repeat = 200; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { sub_preset = app->subs_preset[i]; - sub_preset_loaded = false; if(furi_string_empty(sub_preset->file_path)) { // FURI_LOG_I(TAG, "Empty file path"); continue; } + + sub_preset_loaded = SubRemLoadSubStateErrorNoFile; + repeat = 200; do { if(!flipper_format_file_open_existing( @@ -305,6 +313,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat } //Load frequency + sub_preset_loaded = SubRemLoadSubStateErrorFreq; if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); sub_preset->freq_preset.frequency = @@ -317,6 +326,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat } //Load preset + sub_preset_loaded = SubRemLoadSubStateErrorMod; if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { FURI_LOG_E(TAG, "Missing Preset"); break; @@ -329,6 +339,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat } //Load protocol + sub_preset_loaded = SubRemLoadSubStateErrorProtocol; if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { FURI_LOG_E(TAG, "Missing Protocol"); break; @@ -375,8 +386,9 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat break; } - sub_preset_loaded = true; - ret |= true; + sub_preset_loaded = SubRemLoadSubStateOK; + ret = SubRemLoadMapStateNotAllOK; + #if FURI_DEBUG FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); #endif @@ -385,9 +397,15 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat // TODO: // Load file state logic // Label depending on the state + // Move to remote scene - if(!sub_preset_loaded) { + if(sub_preset_loaded != SubRemLoadSubStateOK) { furi_string_set_str(sub_preset->label, "N/A"); + all_loaded = false; + } + + if(ret != SubRemLoadMapStateErrorBrokenFile && all_loaded) { + ret = SubRemLoadMapStateOK; } flipper_format_file_close(fff_data_file); @@ -397,7 +415,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat return ret; } -bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { +SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { furi_assert(app); furi_assert(file_path); #if FURI_DEBUG @@ -405,7 +423,7 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { #endif Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); - bool ret = false; + SubRemLoadMapState ret = SubRemLoadMapStateErrorOpenError; #if FURI_DEBUG FURI_LOG_I(TAG, "Open Map File.."); #endif @@ -413,20 +431,23 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { if(!flipper_format_file_open_existing(fff_data_file, file_path)) { FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); + ret = SubRemLoadMapStateErrorOpenError; } else { if(!subrem_map_preset_load(app, fff_data_file)) { FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); // ret = // error for popup - } else if( - (flipper_format_file_close(fff_data_file)) && - (subrem_map_preset_check(app, fff_data_file))) { - FURI_LOG_I(TAG, "Load Map File Seccesful"); - ret = true; + } else if(!flipper_format_file_close(fff_data_file)) { + ret = SubRemLoadMapStateErrorOpenError; + } else { + ret = subrem_map_preset_check(app, fff_data_file); } } - // TODO: Popup for error or return error type - if(!ret) { + if(ret == SubRemLoadMapStateOK) { + FURI_LOG_I(TAG, "Load Map File Seccesful"); + } else if(ret == SubRemLoadMapStateNotAllOK) { + FURI_LOG_I(TAG, "Load Map File Seccesful [Not all files]"); + } else { FURI_LOG_E(TAG, "Broken Map File"); } @@ -434,7 +455,6 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { flipper_format_free(fff_data_file); furi_record_close(RECORD_STORAGE); - return ret; } @@ -450,10 +470,8 @@ SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) { // Input events and views are managed by file_select if(!dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options)) { - } else if(subrem_map_file_load(app, furi_string_get_cstr(app->file_path))) { - ret = SubRemLoadMapStateOK; } else { - ret = SubRemLoadMapStateError; + ret = subrem_map_file_load(app, furi_string_get_cstr(app->file_path)); } furi_string_free(file_path); diff --git a/applications/main/subghz_remote/subghz_remote_app_i.h b/applications/main/subghz_remote/subghz_remote_app_i.h index 1cbdbd5cd0..40d70411ab 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.h +++ b/applications/main/subghz_remote/subghz_remote_app_i.h @@ -42,6 +42,7 @@ typedef struct { FuriString* protocaol_name; FuriString* label; SubGhzProtocolType type; + SubRemLoadSubState load_state; } SubRemSubFilePreset; SubRemSubFilePreset* subrem_sub_file_preset_alloc(); @@ -70,8 +71,6 @@ typedef struct { bool tx_running; uint8_t chusen_sub; - - // TODO: LoadFileError } SubGhzRemoteApp; SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app); diff --git a/applications/main/subghz_remote/views/remote.c b/applications/main/subghz_remote/views/remote.c index 85c63568ea..1f867cd0b6 100644 --- a/applications/main/subghz_remote/views/remote.c +++ b/applications/main/subghz_remote/views/remote.c @@ -4,7 +4,7 @@ #include #include -#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 16 +#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 12 struct SubRemViewRemote { View* view; From a4d72e0fee973638c393a23c2819926ded35c3f0 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 19 May 2023 12:32:35 +0300 Subject: [PATCH 24/92] subrem fix repeat --- .../main/subghz_remote/subghz_remote_app_i.c | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/applications/main/subghz_remote/subghz_remote_app_i.c b/applications/main/subghz_remote/subghz_remote_app_i.c index 9b0f77d17c..171618a5f8 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.c +++ b/applications/main/subghz_remote/subghz_remote_app_i.c @@ -129,23 +129,31 @@ bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); bool saved = false; + uint32_t repeat = 200; FuriString* file_dir = furi_string_alloc(); path_extract_dirname(dev_file_name, file_dir); do { - //removing additional fields + // removing additional fields flipper_format_delete_key(flipper_format, "Repeat"); - //flipper_format_delete_key(flipper_format, "Manufacture"); + // flipper_format_delete_key(flipper_format, "Manufacture"); if(!storage_simply_remove(storage, dev_file_name)) { break; } + //ToDo check Write stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); + if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + saved = true; } while(0); + furi_string_free(file_dir); furi_record_close(RECORD_STORAGE); return saved; @@ -267,7 +275,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat bool ret = false; bool sub_preset_loaded = false; SubRemSubFilePreset* sub_preset; - + uint32_t repeat = 200; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { sub_preset = app->subs_preset[i]; sub_preset_loaded = false; @@ -275,6 +283,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat // FURI_LOG_I(TAG, "Empty file path"); continue; } + repeat = 200; do { if(!flipper_format_file_open_existing( fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { @@ -361,6 +370,11 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat FURI_LOG_E(TAG, "Protocol does not support transmission"); } + if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + sub_preset_loaded = true; ret |= true; #if FURI_DEBUG From 561b54ce361c9627cb968f48bf2c3cab5c205b23 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sat, 20 May 2023 09:38:44 +0300 Subject: [PATCH 25/92] SubGHz App: alloc balance --- applications/main/subghz/scenes/subghz_scene_decode_raw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_decode_raw.c b/applications/main/subghz/scenes/subghz_scene_decode_raw.c index e88da3749f..102965df5b 100644 --- a/applications/main/subghz/scenes/subghz_scene_decode_raw.c +++ b/applications/main/subghz/scenes/subghz_scene_decode_raw.c @@ -179,11 +179,12 @@ void subghz_scene_decode_raw_on_enter(void* context) { furi_string_get_cstr(item_time), subghz_history_get_type_protocol(subghz->history, i)); } - furi_string_free(item_name); - furi_string_free(item_time); subghz_view_receiver_set_idx_menu(subghz->subghz_receiver, subghz->idx_menu_chosen); } + furi_string_free(item_name); + furi_string_free(item_time); + subghz_scene_receiver_update_statusbar(subghz); view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdReceiver); From 87ebbc990142a729a04b4baaa6f3b2f0454d0ae5 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 20 May 2023 09:52:00 +0300 Subject: [PATCH 26/92] Update wifi marauder --- .../scenes/wifi_marauder_scene_config.h | 1 + .../wifi_marauder_scene_sniffpmkid_options.c | 117 ++++++++++++++++++ .../scenes/wifi_marauder_scene_start.c | 19 +-- .../wifi_marauder_app.h | 2 +- .../wifi_marauder_app_i.h | 2 +- .../wifi_marauder_custom_event.h | 3 +- 6 files changed, 134 insertions(+), 10 deletions(-) create mode 100644 applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_sniffpmkid_options.c diff --git a/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_config.h b/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_config.h index ae976c6bfd..d223af79ad 100644 --- a/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_config.h +++ b/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_config.h @@ -12,3 +12,4 @@ ADD_SCENE(wifi_marauder, script_confirm_delete, ScriptConfirmDelete) ADD_SCENE(wifi_marauder, script_stage_edit, ScriptStageEdit) ADD_SCENE(wifi_marauder, script_stage_add, ScriptStageAdd) ADD_SCENE(wifi_marauder, script_stage_edit_list, ScriptStageEditList) +ADD_SCENE(wifi_marauder, sniffpmkid_options, SniffPmkidOptions) diff --git a/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_sniffpmkid_options.c b/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_sniffpmkid_options.c new file mode 100644 index 0000000000..02869030e7 --- /dev/null +++ b/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_sniffpmkid_options.c @@ -0,0 +1,117 @@ +#include "../wifi_marauder_app_i.h" + +enum SubmenuIndex { + SubmenuIndexPassive, + SubmenuIndexActive, + SubmenuIndexTargetedPassive, + SubmenuIndexTargetedActive, + SubmenuIndexChannelPassive, + SubmenuIndexChannelActive, +}; + +static void wifi_marauder_scene_sniffpmkid_options_callback(void* context, uint32_t index) { + WifiMarauderApp* app = context; + + app->is_custom_tx_string = false; // this will be set if needed by text input + switch(index) { + case SubmenuIndexPassive: + app->selected_tx_string = "sniffpmkid"; + scene_manager_set_scene_state( + app->scene_manager, WifiMarauderSceneSniffPmkidOptions, index); + scene_manager_next_scene(app->scene_manager, WifiMarauderSceneConsoleOutput); + break; + case SubmenuIndexActive: + app->selected_tx_string = "sniffpmkid -d"; + scene_manager_set_scene_state( + app->scene_manager, WifiMarauderSceneSniffPmkidOptions, index); + scene_manager_next_scene(app->scene_manager, WifiMarauderSceneConsoleOutput); + break; + case SubmenuIndexTargetedPassive: + app->selected_tx_string = "sniffpmkid -l"; + scene_manager_set_scene_state( + app->scene_manager, WifiMarauderSceneSniffPmkidOptions, index); + scene_manager_next_scene(app->scene_manager, WifiMarauderSceneConsoleOutput); + break; + case SubmenuIndexTargetedActive: + app->selected_tx_string = "sniffpmkid -d -l"; + scene_manager_set_scene_state( + app->scene_manager, WifiMarauderSceneSniffPmkidOptions, index); + scene_manager_next_scene(app->scene_manager, WifiMarauderSceneConsoleOutput); + break; + case SubmenuIndexChannelPassive: + app->selected_tx_string = "sniffpmkid -c"; + scene_manager_set_scene_state( + app->scene_manager, WifiMarauderSceneSniffPmkidOptions, index); + scene_manager_next_scene(app->scene_manager, WifiMarauderSceneTextInput); + break; + case SubmenuIndexChannelActive: + app->selected_tx_string = "sniffpmkid -d -c"; + scene_manager_set_scene_state( + app->scene_manager, WifiMarauderSceneSniffPmkidOptions, index); + scene_manager_next_scene(app->scene_manager, WifiMarauderSceneTextInput); + break; + } +} + +void wifi_marauder_scene_sniffpmkid_options_on_enter(void* context) { + WifiMarauderApp* app = context; + + Submenu* submenu = app->submenu; + + submenu_set_header(submenu, "Sniff PMKID"); + submenu_add_item( + submenu, + "Passive", + SubmenuIndexPassive, + wifi_marauder_scene_sniffpmkid_options_callback, + app); + submenu_add_item( + submenu, + "Active (Force Deauth)", + SubmenuIndexActive, + wifi_marauder_scene_sniffpmkid_options_callback, + app); + submenu_add_item( + submenu, + "Targeted Passive (List)", + SubmenuIndexTargetedPassive, + wifi_marauder_scene_sniffpmkid_options_callback, + app); + submenu_add_item( + submenu, + "Targeted Active (List)", + SubmenuIndexTargetedActive, + wifi_marauder_scene_sniffpmkid_options_callback, + app); + submenu_add_item( + submenu, + "On Channel # - Passive", + SubmenuIndexChannelPassive, + wifi_marauder_scene_sniffpmkid_options_callback, + app); + submenu_add_item( + submenu, + "On Channel # - Active", + SubmenuIndexChannelActive, + wifi_marauder_scene_sniffpmkid_options_callback, + app); + + submenu_set_selected_item( + submenu, + scene_manager_get_scene_state(app->scene_manager, WifiMarauderSceneSniffPmkidOptions)); + view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewSubmenu); +} + +bool wifi_marauder_scene_sniffpmkid_options_on_event(void* context, SceneManagerEvent event) { + //WifiMarauderApp* app = context; + UNUSED(context); + UNUSED(event); + bool consumed = false; + + return consumed; +} + +void wifi_marauder_scene_sniffpmkid_options_on_exit(void* context) { + WifiMarauderApp* app = context; + submenu_reset(app->submenu); +} diff --git a/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c b/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c index 6f22d0adb0..28a3ed2a93 100644 --- a/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c +++ b/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c @@ -97,13 +97,6 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = { NO_ARGS, FOCUS_CONSOLE_END, SHOW_STOPSCAN_TIP}, - {"Sniff PMKID", - {"ap", "channel"}, - 2, - {"sniffpmkid -d -l", "sniffpmkid -c"}, - TOGGLE_ARGS, - FOCUS_CONSOLE_END, - SHOW_STOPSCAN_TIP}, {"Channel", {"get", "set"}, 2, @@ -161,6 +154,14 @@ static void wifi_marauder_scene_start_var_list_enter_callback(void* context, uin return; } + if(app->selected_tx_string && + strncmp("sniffpmkid", app->selected_tx_string, strlen("sniffpmkid")) == 0) { + // sniffpmkid submenu + view_dispatcher_send_custom_event( + app->view_dispatcher, WifiMarauderEventStartSniffPmkidOptions); + return; + } + // Select automation script if(index == NUM_MENU_ITEMS - 2) { view_dispatcher_send_custom_event( @@ -254,6 +255,10 @@ bool wifi_marauder_scene_start_on_event(void* context, SceneManagerEvent event) scene_manager_set_scene_state( app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index); scene_manager_next_scene(app->scene_manager, WifiMarauderSceneScriptSelect); + } else if(event.event == WifiMarauderEventStartSniffPmkidOptions) { + scene_manager_set_scene_state( + app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index); + scene_manager_next_scene(app->scene_manager, WifiMarauderSceneSniffPmkidOptions); } consumed = true; } else if(event.type == SceneManagerEventTypeTick) { diff --git a/applications/external/wifi_marauder_companion/wifi_marauder_app.h b/applications/external/wifi_marauder_companion/wifi_marauder_app.h index 303fb59b41..7e38560592 100644 --- a/applications/external/wifi_marauder_companion/wifi_marauder_app.h +++ b/applications/external/wifi_marauder_companion/wifi_marauder_app.h @@ -4,7 +4,7 @@ extern "C" { #endif -#define WIFI_MARAUDER_APP_VERSION "v0.3.5" +#define WIFI_MARAUDER_APP_VERSION "v0.3.6" typedef struct WifiMarauderApp WifiMarauderApp; diff --git a/applications/external/wifi_marauder_companion/wifi_marauder_app_i.h b/applications/external/wifi_marauder_companion/wifi_marauder_app_i.h index 2a16522bb3..45e1e59207 100644 --- a/applications/external/wifi_marauder_companion/wifi_marauder_app_i.h +++ b/applications/external/wifi_marauder_companion/wifi_marauder_app_i.h @@ -26,7 +26,7 @@ #include #include -#define NUM_MENU_ITEMS (18) +#define NUM_MENU_ITEMS (17) #define WIFI_MARAUDER_TEXT_BOX_STORE_SIZE (4096) #define WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE (512) diff --git a/applications/external/wifi_marauder_companion/wifi_marauder_custom_event.h b/applications/external/wifi_marauder_companion/wifi_marauder_custom_event.h index 5acdfa38ed..b6d9f8274e 100644 --- a/applications/external/wifi_marauder_companion/wifi_marauder_custom_event.h +++ b/applications/external/wifi_marauder_companion/wifi_marauder_custom_event.h @@ -8,5 +8,6 @@ typedef enum { WifiMarauderEventSaveDestinationMac, WifiMarauderEventStartSettingsInit, WifiMarauderEventStartLogViewer, - WifiMarauderEventStartScriptSelect + WifiMarauderEventStartScriptSelect, + WifiMarauderEventStartSniffPmkidOptions } WifiMarauderCustomEvent; From 1ea138f7952ac9bce054ade7add4868694a24ce2 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 20 May 2023 10:01:05 +0300 Subject: [PATCH 27/92] Port XFW keyboard to marauder instead of UART Term keyboard This implementation has not only extra symbols but a cursor feature thanks to @Willy-JL --- .../assets/KeyKeyboardSelected_10x11.png | Bin 0 -> 7210 bytes .../assets/KeyKeyboard_10x11.png | Bin 0 -> 7763 bytes .../wifi_marauder_text_input.c | 557 +++++++++++------- .../wifi_marauder_text_input.h | 31 +- 4 files changed, 357 insertions(+), 231 deletions(-) create mode 100644 applications/external/wifi_marauder_companion/assets/KeyKeyboardSelected_10x11.png create mode 100644 applications/external/wifi_marauder_companion/assets/KeyKeyboard_10x11.png diff --git a/applications/external/wifi_marauder_companion/assets/KeyKeyboardSelected_10x11.png b/applications/external/wifi_marauder_companion/assets/KeyKeyboardSelected_10x11.png new file mode 100644 index 0000000000000000000000000000000000000000..231880386a9d9e83911088c9fcd083f84a7f75bb GIT binary patch literal 7210 zcmeHMc{G&m`=?Ublaz#}DWMw1jBO@scCroG3eED&7|aYa!&oaSQQ1?BvQr3^B_u>D zRI(HaN!GGvr}BHKx3~9vzvukUd(Q9oUvtjPbKlo}U7!29KG${M=ef>=S(q8{^N8_q zaB%P&8R}xd=jxbu^9JyDl++f>!NK>$&)SZO!LlG8bQ+QD4nUZ`9smUJArm<`d^+pBC6Dvw@S z{-)=@qQ^b|b+J}=KD@%AUv=la?m*JB2h-;tO5d8_imCrneonb*>iaiOoi~|NgFw@_ z>-`^xAU-r*IlrN-```Pz{aJjIOYe6%&l?S#KG|D$Cg<#&2dHBbiv7Hj8*N; zvpssiU{m_6Dsp$aNSFHK(;jp`NzI2;_pfRP-p$Ih1Qswm1DPBQr;lPomFj({Au*WtuGPPB=1`JJ~?+kaqp}DZ~9^g`Gj^RetXd*K0SH zJ19>d_hxz4gfY4o0~P!|>%7uPfv>JPngvYNlF~X@9cNkQ$44tEW#w;Kja|NWA?QYe z&H9z@Ym4K8Z!j`;{@pL7VRsr)Udlw5{+SzC-N*UwvONzkOf40U z>Rp-(=l&{CL^|2;(~ASTgnOY>356$qP_4Gxk;-pPt_!<)6839}w2C0ZH+P73R~zoA zFn_%N@Ixg{p$8YrhfCc{1rmh9hGTc&tOBI$_UL{wII{nO>x{xZV%vvv9Gd= zx{Pyg%#5TyO)8)1GAXF#*X)gq4!Nw>aI4h}Lk`(VVk4#x70O{KzJ)ax55nwywR#plr`5U|#GaS+K)ep~wM#|o9F=~q!f|G)!`qK75Qg1vNZBX8DGrBe2k!xwX z8B1u3=g$?|8;o_>aV_xi%Ti&>@Gj@N7luANROW9+BgM*T`r}Va1Gg8a0=FhYCAQ^Q z$qO!tS~(8BA870=lvwJyG|^ZNKy+-SwRsn`(Ul~Jjs4jZ$SbmC&)D64$#vG5B_l;1 z6Gq7f(^ECck_j$KLHIjw&JR3@bTuk>{YbD=Q_Yu=+$iWKA`Nur?CliUD~Z;CZ_axwEAz6nXHiQ|V(3?+8UAD0poEjPNp z!=4qc+*xD0C(f9CuE+RU>&Is!iU}1;H!p|xdE`EA_152&_U7A!#0%R^F}jGL46$AH zvN_wVQx**-Ns@z5UW{xuK9(a%@<76{xaxVs#0U2#!jvjihd!`91^f#PV{Xfmd#WC~~ete1cf9 z+fj!7dz04|rn`8u$6klHW{xx~EZCu6o1cGPbJWqCUzB9NRq;ubLEU}+i?7e;1jRO# z+c{ru?F{Ov**2A$KZvV~MLjJYOzFJ>b+Gsv=Wq86Uv;tPMcyPSNYh|?cDLcfjI)e0 zEgRho44AL@mP}3v&FHAz33PG8oo?9Vb|vIkE!{HY(6E?&)p~USUztO-==j{D_fs6S z?pF_^Bdo5;urkh85bzqMmr}VJc)0?O`vj`7lLMz__ujs7DdzNS>!LP-??O_Dl|$$x z(M@70&Y@Mj7#E-J^wvy&+wR6r`^mm7(>;3~#7{quo|mn0V6+)CDFp+iWon z-**4Ih^W!fEm`Gp=WC&lQbJBBh;#ziZNeg^@P<1}R9Y)$&fPxouwzgtChxVH{2fbT z7-ML@+(Gz`+2evrWYre4V*q(DPP-|sg&1b{zTZPK?C?82<8e2u1J9z1O4TpDf8~|> zQr-TE=>9_QAhl1O%=OcsA;;egY%+@ebo;AaQD>RihkW?Hv6!1Sf>aUCvx2DFFku1t z8?)QiCr6ChZuLJ(G#k%VIv}&Cl8YK^T6bDx!*roc!1fJo`f{HIYNQY{K72ffUC-gI zHAJe!xZ-6L@8+3qu1J>^FSMW$Bzd>@SHWbX`NXDAH0sD0oW49iZ%}Biku~Bla&n?~ zyN3S}=Wh!_U(4MK+Y3^f6)nlt2<A+q)6|<9u^{Hh0X&}JX;5(Xg=2C>r zm*t^Z%&r-}cdW^qkgAfDef~9dQ+ya$#WWa%<4^$Wu2ukS9Z0liiAG0pbA$!)Z8Uq#Yfwh zqDg$_FNsX-I&Gz~l)6~`DniZiIAi=^*anaCQ?RJRpWoA+CNfYfFRrLmNlt#|dYDyV zpG^9Cyk=epmzRvzua??W$}-Q1qJ>r{2W{4p)|Ajyz7&26GjQgVThTD3T~A7+KtL>2 zGA&c-k)Y>0e|&?u1$Hv^ob>H&0m~O1Jcn$o$Jtkm5up`aa_ui!xZa~x)^6U4TW)b& zX{S5zW}TE8yk=8gKt-hCzq0#yOAc+e?UX9q{oOk>RHWdzN;=6VbEW&Sd7|gcLiwfn zCR}bkzxZUcpHA(1-qVnk7fqEe>m7Zy8`vEl55;N@yxOrZ*x8GaBeBg4zoGspsbc@_ z@w1(qvvS(hFkPFYCWyWUWbS#&-W7)O`^h#J^$DLDbs)c+t41)8f)SO@HUMj|=3!Nt-&#P)G@e3IF#4Ecrw~5{EoL=*TYvGGo1>S-guq# zgWPpb%Gi2x{V5fhZb=HwZ!WusFW8K<1vJBkgJ@Cqo~K$2z74umF0ZGT;1&wyOi*5L z9~bc=Bi_7zobDi!)F~xX>k@hAp_OAdUu;q!%Az#WC8MP>HfaZu+^NvNKzbEIwCCpwD-o3Xa;iXcb_; z1H+*~zx9!AEwVmQjWXJ4;wbsZu7|K>J}S{JtN8s8rP1r#%z-!4us4BM^Zko8sxMkU zfSmQZr@Q2XJL8gmI`Qrvp4(L5Lx*(o6=YGB=MTFMs-`QQZ z)5s~^@J?DzB1yE+X89hA86oig#t7bg$m2lwNH#R8LCztxS8s8YluL4}d3Yx^$o80w zacig)w3_dOwbHoGU}CG#>+rMDZ}9UYDO#T!-v+u0yEk7Q?Y^12BtAbat;d<&?M3TP z)Lkx2UliNBk`(o#U378&oO|VyXH}Z)2_*AUD7CxJz0)Z>Btb8yxiet~>!O{XDoRWc z=sZc5E3NSo-z3Rq0~NV;fTRZT{o@InNIke(DtO~jN$j~feLel zkx|b!@dQP>7#7{q2|r5CDt6HNbadaHo9#!J_sGqjFy&YnN^Sa2CWFu|=vnG8Db`}j_G%ze?xY__Z+*K=t$HMC|n%BrJ@v)+*XbjmpV zCV%2!dz0AQG)MHZua-;X5T}|Fd@u<86oI z^A*lpZr5T9ikrDOI5?qX9UTiJ9i6{A8nBPKek1CxajnI+kgBXS=z(A;RAA?c!=3ey za<=gB+_izDGgV;QV?|@G^zB;MzXX@q@W|G~)?==!`O%|8PO4vbUtoM+>EVsom6#EK z_{=^SqoAEz?(9L<2mT8%_U*f3Z0P5O@7%>h({UlMuU(zZNnW0QZctleNXls=_;QB_ zdipyMuO4&nn)5g4+jMuA6nWpNtrPl2gty~!F+R9cYGahE7e?yJ#&W$Uhv^q18_#g# zamEfU);I8-qeklVBjd90miSaZs~1|-VI!NC#6o;1?oh4_J?3o!6>vImn)qe50Ou{fF+QymHg z*CBuTNAWN<{RK~D{A2;-L*57LA+I0@m#0wVf45*T^}IolpAP+33x+k=M$2OW2F;6( z2lTuFDs%7e5Cr@$dk-(V`&u{zygc9zP(W1%xU0fHwlpv@wfJSRN&$&X@mRA0$^M5X zlT7@Ztbh2ny0R9|?~Z`xzi|Jd{a5U3%Al61DO#6?_gZz&NLL-Yx<8sg!;=ZpiDj{I11RM^A$K#X;D1d;66I6eLGNLk=SSlV^g#y9l$RG}YQc)x* zsUTrEWmQ#}B1)AA!x2?M2pmos1t%(kIQZWn%;{vXDzWard$kHh0HJUQ6dq3`sKQk7 z$|^8LMI{x`8w3DTLgL_n0u~ELsw%8O5%6ez8l8d#(@CaaNr1cum9)07N;q2E!bly8 zkc0m%v2e#SiJ*Zx^eCC?<@5J~HJJifF|n&`Dk!U{AmAt^MT81cMMVYqw~`G&XMmNs zim3pXLn78zR?~t8g8_-fuGT3CuqFp%LF>=~ER#mJrqSHhp{p)IRxN)mn}WxQfMsHJ zu}lC2g(Hw?I0B7Ow1y+mNN|8S2#2HLzvgv{X%EZh)foi4rr4=9zm|a@?7HzBD0n# z*?;=NasgJe01^g+BVhkYnEcOxo))aobWI($gGVt;O??U-sm*G#& zK!5)~KR~vOSwT8}y5Z6&x`A8PBTVZMP{#YRdS&a^gaPJ@ k(Oa(fF60b8WFS2`E^HCx5!~3>143{Z>6z)~A2}KPKg=ZgNB{r; literal 0 HcmV?d00001 diff --git a/applications/external/wifi_marauder_companion/assets/KeyKeyboard_10x11.png b/applications/external/wifi_marauder_companion/assets/KeyKeyboard_10x11.png new file mode 100644 index 0000000000000000000000000000000000000000..1f4c03478f68cb15c74ef99888ce4faf50e0a140 GIT binary patch literal 7763 zcmeHMcT|(hwg*8VAW}pT5e%V7OCh9?P?TPzgMbtONN-0#Ksbt`qQDF2@p$jMYrS>WdiTGRwen?V&)&b;`?vSZ`eqVoY^cr2evF-g zfq_$3N5ho90!va7!EG^n_JOLaXvtIPYQ|bLIl$M+=)P1CL*XpT|J)pSw`V*_Er$lGUV9}kPM4|w*oUQF?ll7f#pMss4lb=^o zxTHFHbLTtx?Ok4rEw7t>D(VkxZfcfTJ7sHGXLrI1f{9&ic>1nxr^!utU*9dyBa?uh zt<9U4zTNzMCU9G9(Yh;AD>cajAe{zue8xJ@Yg`6yOC0zLuJnr?{uC$hz$J!1t$O8Z z{Ij)7kNrj6`_Cz6d1P2Fte8CNzMOA6aWZ8mTM&she@Jegv}p%ETlw%=%BfQ0?9PX~ zT<5QUd04Y5|8c}-@_bFLkydQn+`w{A*uwddyO(PoJR82gHV_($1!NJc)^8hP1lU9Zl+Z^xD0YX>z1jRVXA=ShPzIG{j?tUd1$5uXpzb%b+lTD z2b_);b06!E6=dp6f=I-iVUTcm69n&=VQe7T!ul5pu5cE0(s6SWJI}i_jE6#mB*~3b zo+*ONne`OHMhVIaB2&sl@&(l{@-|78&dRPay-Nyenss(>xytRJBXX7ZBCWrZ8?SG2 zx?CcyK~JPT+0;;cXyw5(k@ua5@1=`W z8c3y;Ti?ENlwI$2_72c<)8{JlK<3$m@hAXh<&Tq6(7sBM9BfW9Dgz_Fly>T@yj?Lc zQ?nbWBB-Sl&boy_$x^=>j?9_78^8SihTeAQ)XJ2m-Q$A=a;E(d5lzX-UdYO|cS42h618SdzYS-CI9A7@(~mPVzJ3&;CuY?)844V_d` zdtM*YoBGXmqH6?{;ArSfbo~91V-={sw)#ULSMlAtwJht8T_cr_b0Eq_rM~{dTXu!W z;MrSTyi|xmiS& zg@pIknVWuh8jj=#3i?h(nqB7av~MqXrsY^7>fu;MzzM-dPt5F-l@JE|c29152hi_tgqdSUNxv_%CV5xX$KDkx3 z3CnUcOS{-qoZ%kl`(>>L@$q*+;jgFCS!bmJL`RvVio!W=Y2t9e_$6*hO`Frj0qcBL zS#X;i;h-nwCW732Xblr5#s}ruxdHY-oD&1lCxlpp;<;$SEL;&?bkD&tPIiEu?O-%| zy1xBY_3O|X#={?YKLND%WxD3hhuNxrodE=`jl%Z%3CrYrddKNXkr+9k1JXi4!nFfX zJ4?6t!y+@2G4b;{Qt7KA48G3_Ca3=}wKzjT-r#}N7bAazy*FCU5gM8c89CChRP@Sy z*mBJKlGm+$n|!e0Lv_}w{!?yu()7yog*3jzdz*+g2_>N|O*A^|C0~|D&)!5;Bid(b zt`7M?w(D5sYbFw389(#>FrsLMJW332BLYztaf%<)Pp;OW-R!T;)x6~}x7df8%8z({i?9Fw30dqk zPFb2k7$5N44No0AQ9nT30q=8Z4{D0MIONu6$5=MHUL0{gaBVsu_;8FGf98lLYh>ZT z^?kafil5OYR+UbcvM;f>$Z5<|#{)QeY3>&MfH@eea_4cXsQ7O~!+A@il8Ymz2VWd= zInDZh;oSl-*`)5mqd`027ZM?#>hq)#Su0L5n;O^e#9)zUSL_qlgrsA=>bUkZ zKCOJ5{hk(2g(0EjQn3vgIf>)gLUmOSnhG=Gv-jiIX@)56y zA8rlm%E#nBlj$2dnJ_`}iammVPPKa6SX$B=<-sa$cR*sHwMuOK>Nd;Rp#1ZI3*-D@ zW16!}9pyPOp6pZSfmh#bM|fH;vG>_Yo)kWkX_gbTD%#hmjVa&cXfqwupI$n=as6rS zy86Q&#b9=xS6awoj!Z@ugsmnwZyJwt#^aSU8kb~|z|USRw_^i9zN!^9N^k?u5^Gdu z)u}w~yt+2hhwSzKLY+_LE!$C4F^hM(+q~fvlY5hoxdj<=xt=MyY>WU{#Yd5iZly3%=9Omm?!k--5ALzv6@ z=i9Y_(81sXSV0+Hlu5GNn{h3D*)n^E`r|`pcXqO&LU-(!8P{bigU@H({%lixSvwSR z-!cx!-_ZO#u=BIv%Wo9ykgTa1G-$*+cKZ7#P6&0~shFV$A0reAMkRzP!iAsIt_ zV2@Iur*CdojvIBy`uBMU8hH;=tJkAel%T0gxL2$PxQ48on#%(Z-oxcEj4!Z2ZulGBZDQCVYdz*#i$zj-uZtXHT5_3S4J6*ao2xHk%-+V%QZ?2vf5D`s zD9`tRgN|P3!SVrGhCG{$@b zhlmo5Bq(hwp|apUmxq zdXRHWoJB8#)@m+eoqhNCN4_}-WD z>DF<9Y#!@qD?0Y_LbAg_iW!`$<<(E8KNxUq6f;}9-(&s~92=I|aMpKTICX_FBGZI8 zNAAvB#6QFBlUQVyIg%aeed9?%m@JQ2+=ULdM>=FzD?fGyN>EyFg{tkrY&GGf3XgZC zC2L=D86IptIWcfTu(3=MWXAn5QBg%O#5QJf0nkNZnd3gy2&uMsno`>4qar@mIVpBp z^~jr>T%#{e)gN-wx}9j}TA6pH>8+SM)nD9M?A%c9xk3bQaunz3FYcm@z~<|!N#jgG zVVx?iw&;|taD~P>19V-}BGao;pT*5YG}^oh~!SY!b5t?b(u1-{z$rMM6WlBOZ~~6Il?In)6pwm3Z(WUwlTAlq@roV};8S z1}EZ7_(}s^YJ6U29}N@&6j;jNnz|M?Sakh4MN4hT>)CqwYYg#4FEIDSjh%p{MvgiWNOgoT0nFGwKFX)YE7f#2o^Aw3+UqQTo`GZ!l^-V&A;@lwdBx+)-% zMtVk}-f39Sv0O+oboNNcD63hl-SguP^r)?-m`M}{mB)LsuQg336{`#T?;K6Yk-f$+ zc0GYZJYGA>QDgGSfpfyaddJw8zNWRCT+H3%Z#S7$+lro*)cy#K${p1D_a~eA&TWM# z%8)&OXN@TGnHkU|9`XuMb(b6=podP)K?Gs+)1=0O#xG2|e|G#bcMF ztesUK_b@^FinJVZiMu_0xp$oITRtKYx3oSDa+M7r$nRTYxc}GC80h6Pkqn8M zSI%oQ9~D2Y+t@dooof7O#8Yaq)shns(c;DwDCzZn5y$oEf@s{E^K61G7n6JZ&(>!} zrUAqc#qqQY)CjDx8E^V}S;YLe1cekg&~FJ2PihMN9WFowBHP0UC)2 zlYCt=H3T%bPNjAynUvpz!WbABL1cAxV_kLiKTo~%vu@^Sz;3=#N1-(Zt1?!+~3k7dtTw&iL2D@ok@;Z z!5eqd6@$dU)Usg!Bvi&{hVv>oqqzK7259;7HlS)@Jtcf7E%jqz&e!!P+O3au918~t zet?)u9s$;*)Uz(*8v)w0tmT5@WU)ZrH7#Aj$m&L-uS1~HTi4X9Z`vQeE%N?j(K9Np zHwb`t(6fGFo`oM>(N*?TTa|*nNWbN8_B44sf*s>`JZcj(aaV#;-?N?qkMFcPkD7_q z$VPE}ZJu&I;W$LXQ&X?_Syg37J0e0pXB=-w{|D=wtB|R|t+kaUeo`UES$-2n-BLr+nRUcxNIF=sYG78 zGC>(+i8O#2xT_PL$U6R>L^FRwbG*MZ9zy_~Qeju}#nJ&>i8LJ0*VV<1iuF|n?crkS z?Oibx1l&`hIV*##42*&56i*@$0YN}uU`=1LHyotG4pj0akg%p2T0bD@J!Oy+jpmMp zLVbLEAU^UCil-w~4uio!VQ?rM4yJ2>seW!WoG;joD!L2t9Ycdi#e0(7X=I8Ua2FHj zK=Gm}gFy6g;Gh1vx*Hh$gmbuCCBuEvPh2Z#u{ihyJ4l)tr9S z0yQO4DPEp|jVAgl1Oflk-rdX7WiK289!hi}y3$pt^jYQpWlC*b1LL0-yA(K* zUETMr=w$zkCXGz`i>!a~ZFgiZoL?QGoBzc97wtb|-&3Y*85m$SD0r`3_jEOsLA&!~ z2^2h;fZc1NF(`Q$3XKQL5#$}f2n84tj6uSYU?dy|L!;3|IR`nyFHpK}R2t3=Puzu~ zgG0!490hrK3`P!v2BXkuc`yP7R{&#BI5ZdzM=2;E5d<6xPx=MI$dgR3N}S8DUhP5= zcAB9w`HZVPU`MQwU^|-~Xk(yLf;~ z-&3wbrqbv4+Y^0XQD#Js@4fF`7xLax0s{9I1r~?@9s(8TP5hp3I@b3gyc5pNkx1V? zew6EAx!J%S)>LeS-Wnmb9nWrR3qxXieCzQocselected_keyboard = (model->selected_keyboard + 1) % keyboard_count; +} + +static uint8_t get_row_size(const Keyboard* keyboard, uint8_t row_index) { + uint8_t row_size = 0; + if(keyboard == &symbol_keyboard) { + switch(row_index + 1) { + case 1: + row_size = COUNT_OF(symbol_keyboard_keys_row_1); + break; + case 2: + row_size = COUNT_OF(symbol_keyboard_keys_row_2); + break; + case 3: + row_size = COUNT_OF(symbol_keyboard_keys_row_3); + break; + default: + furi_crash(NULL); + } + } else { + switch(row_index + 1) { + case 1: + row_size = COUNT_OF(keyboard_keys_row_1); + break; + case 2: + row_size = COUNT_OF(keyboard_keys_row_2); + break; + case 3: + row_size = COUNT_OF(keyboard_keys_row_3); + break; + default: + furi_crash(NULL); + } } return row_size; } -static const WIFI_TextInputKey* get_row(uint8_t row_index) { +static const WIFI_TextInputKey* get_row(const Keyboard* keyboard, uint8_t row_index) { const WIFI_TextInputKey* row = NULL; - - switch(row_index + 1) { - case 1: - row = keyboard_keys_row_1; - break; - case 2: - row = keyboard_keys_row_2; - break; - case 3: - row = keyboard_keys_row_3; - break; - case 4: - row = keyboard_keys_row_4; - break; + if(row_index < 3) { + row = keyboard->rows[row_index]; + } else { + furi_crash(NULL); } return row; } static char get_selected_char(WIFI_TextInputModel* model) { - return get_row(model->selected_row)[model->selected_column].text; + return get_row( + keyboards[model->selected_keyboard], model->selected_row)[model->selected_column] + .text; } static bool char_is_lowercase(char letter) { @@ -165,36 +231,9 @@ static bool char_is_lowercase(char letter) { } static char char_to_uppercase(const char letter) { - switch(letter) { - case '_': + if(letter == '_') { return 0x20; - break; - case '(': - return 0x29; - break; - case '{': - return 0x7d; - break; - case '[': - return 0x5d; - break; - case '/': - return 0x5c; - break; - case ';': - return 0x3a; - break; - case '.': - return 0x2c; - break; - case '!': - return 0x3f; - break; - case '<': - return 0x3e; - break; - } - if(char_is_lowercase(letter)) { + } else if(char_is_lowercase(letter)) { return (letter - 0x20); } else { return letter; @@ -202,86 +241,96 @@ static char char_to_uppercase(const char letter) { } static void wifi_text_input_backspace_cb(WIFI_TextInputModel* model) { - uint8_t text_length = model->clear_default_text ? 1 : strlen(model->text_buffer); - if(text_length > 0) { - model->text_buffer[text_length - 1] = 0; + if(model->clear_default_text) { + model->text_buffer[0] = 0; + model->cursor_pos = 0; + } else if(model->cursor_pos > 0) { + char* move = model->text_buffer + model->cursor_pos; + memmove(move - 1, move, strlen(move) + 1); + model->cursor_pos--; } } static void wifi_text_input_view_draw_callback(Canvas* canvas, void* _model) { WIFI_TextInputModel* model = _model; - //uint8_t text_length = model->text_buffer ? strlen(model->text_buffer) : 0; + uint8_t text_length = model->text_buffer ? strlen(model->text_buffer) : 0; uint8_t needed_string_width = canvas_width(canvas) - 8; uint8_t start_pos = 4; - const char* text = model->text_buffer; + model->cursor_pos = model->cursor_pos > text_length ? text_length : model->cursor_pos; + size_t cursor_pos = model->cursor_pos; canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); - canvas_draw_str(canvas, 2, 7, model->header); - elements_slightly_rounded_frame(canvas, 1, 8, 126, 12); - - if(canvas_string_width(canvas, text) > needed_string_width) { - canvas_draw_str(canvas, start_pos, 17, "..."); - start_pos += 6; - needed_string_width -= 8; - } + canvas_draw_str(canvas, 2, 8, model->header); + elements_slightly_rounded_frame(canvas, 1, 12, 126, 15); - while(text != 0 && canvas_string_width(canvas, text) > needed_string_width) { - text++; + char buf[model->text_buffer_size + 1]; + if(model->text_buffer) { + strlcpy(buf, model->text_buffer, sizeof(buf)); } + char* str = buf; if(model->clear_default_text) { elements_slightly_rounded_box( - canvas, start_pos - 1, 14, canvas_string_width(canvas, text) + 2, 10); + canvas, start_pos - 1, 14, canvas_string_width(canvas, str) + 2, 10); canvas_set_color(canvas, ColorWhite); } else { - canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 1, 18, "|"); - canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 2, 18, "|"); + char* move = str + cursor_pos; + memmove(move + 1, move, strlen(move) + 1); + str[cursor_pos] = '|'; + } + + if(cursor_pos > 0 && canvas_string_width(canvas, str) > needed_string_width) { + canvas_draw_str(canvas, start_pos, 22, "..."); + start_pos += 6; + needed_string_width -= 8; + for(uint32_t off = 0; + strlen(str) && canvas_string_width(canvas, str) > needed_string_width && + off < cursor_pos; + off++) { + str++; + } + } + + if(canvas_string_width(canvas, str) > needed_string_width) { + needed_string_width -= 4; + size_t len = strlen(str); + while(len && canvas_string_width(canvas, str) > needed_string_width) { + str[len--] = '\0'; + } + strcat(str, "..."); } - canvas_draw_str(canvas, start_pos, 17, text); + + canvas_draw_str(canvas, start_pos, 22, str); canvas_set_font(canvas, FontKeyboard); - for(uint8_t row = 0; row <= keyboard_row_count; row++) { - const uint8_t column_count = get_row_size(row); - const WIFI_TextInputKey* keys = get_row(row); + for(uint8_t row = 0; row < keyboard_row_count; row++) { + const uint8_t column_count = get_row_size(keyboards[model->selected_keyboard], row); + const WIFI_TextInputKey* keys = get_row(keyboards[model->selected_keyboard], row); for(size_t column = 0; column < column_count; column++) { + bool selected = !model->cursor_select && model->selected_row == row && + model->selected_column == column; + const Icon* icon = NULL; if(keys[column].text == ENTER_KEY) { - canvas_set_color(canvas, ColorBlack); - if(model->selected_row == row && model->selected_column == column) { - canvas_draw_icon( - canvas, - keyboard_origin_x + keys[column].x, - keyboard_origin_y + keys[column].y, - &I_KeySaveSelected_24x11); - } else { - canvas_draw_icon( - canvas, - keyboard_origin_x + keys[column].x, - keyboard_origin_y + keys[column].y, - &I_KeySave_24x11); - } + icon = selected ? &I_KeySaveSelected_24x11 : &I_KeySave_24x11; + } else if(keys[column].text == SWITCH_KEYBOARD_KEY) { + icon = selected ? &I_KeyKeyboardSelected_10x11 : &I_KeyKeyboard_10x11; } else if(keys[column].text == BACKSPACE_KEY) { - canvas_set_color(canvas, ColorBlack); - if(model->selected_row == row && model->selected_column == column) { - canvas_draw_icon( - canvas, - keyboard_origin_x + keys[column].x, - keyboard_origin_y + keys[column].y, - &I_KeyBackspaceSelected_16x9); - } else { - canvas_draw_icon( - canvas, - keyboard_origin_x + keys[column].x, - keyboard_origin_y + keys[column].y, - &I_KeyBackspace_16x9); - } + icon = selected ? &I_KeyBackspaceSelected_16x9 : &I_KeyBackspace_16x9; + } + canvas_set_color(canvas, ColorBlack); + if(icon != NULL) { + canvas_draw_icon( + canvas, + keyboard_origin_x + keys[column].x, + keyboard_origin_y + keys[column].y, + icon); } else { - if(model->selected_row == row && model->selected_column == column) { - canvas_set_color(canvas, ColorBlack); + if(selected) { canvas_draw_box( canvas, keyboard_origin_x + keys[column].x - 1, @@ -289,19 +338,25 @@ static void wifi_text_input_view_draw_callback(Canvas* canvas, void* _model) { 7, 10); canvas_set_color(canvas, ColorWhite); - } else { - canvas_set_color(canvas, ColorBlack); } - canvas_draw_glyph( - canvas, - keyboard_origin_x + keys[column].x, - keyboard_origin_y + keys[column].y, - keys[column].text); + if(model->clear_default_text || text_length == 0) { + canvas_draw_glyph( + canvas, + keyboard_origin_x + keys[column].x, + keyboard_origin_y + keys[column].y, + char_to_uppercase(keys[column].text)); + } else { + canvas_draw_glyph( + canvas, + keyboard_origin_x + keys[column].x, + keyboard_origin_y + keys[column].y, + keys[column].text); + } } } } - if(model->valadator_message_visible) { + if(model->validator_message_visible) { canvas_set_font(canvas, FontSecondary); canvas_set_color(canvas, ColorWhite); canvas_draw_box(canvas, 8, 10, 110, 48); @@ -319,37 +374,69 @@ static void UNUSED(wifi_text_input); if(model->selected_row > 0) { model->selected_row--; - if(model->selected_column > get_row_size(model->selected_row) - 6) { + if(model->selected_row == 0 && + model->selected_column > + get_row_size(keyboards[model->selected_keyboard], model->selected_row) - 6) { model->selected_column = model->selected_column + 1; } + if(model->selected_row == 1 && + model->selected_keyboard == symbol_keyboard.keyboard_index) { + if(model->selected_column > 5) + model->selected_column += 2; + else if(model->selected_column > 1) + model->selected_column += 1; + } + } else { + model->cursor_select = true; + model->clear_default_text = false; } } static void wifi_text_input_handle_down(WIFI_TextInput* wifi_text_input, WIFI_TextInputModel* model) { UNUSED(wifi_text_input); - if(model->selected_row < keyboard_row_count - 1) { + if(model->cursor_select) { + model->cursor_select = false; + } else if(model->selected_row < keyboard_row_count - 1) { model->selected_row++; - if(model->selected_column > get_row_size(model->selected_row) - 4) { + if(model->selected_row == 1 && + model->selected_column > + get_row_size(keyboards[model->selected_keyboard], model->selected_row) - 4) { model->selected_column = model->selected_column - 1; } + if(model->selected_row == 2 && + model->selected_keyboard == symbol_keyboard.keyboard_index) { + if(model->selected_column > 7) + model->selected_column -= 2; + else if(model->selected_column > 1) + model->selected_column -= 1; + } } } static void wifi_text_input_handle_left(WIFI_TextInput* wifi_text_input, WIFI_TextInputModel* model) { UNUSED(wifi_text_input); - if(model->selected_column > 0) { + if(model->cursor_select) { + if(model->cursor_pos > 0) { + model->cursor_pos = CLAMP(model->cursor_pos - 1, strlen(model->text_buffer), 0u); + } + } else if(model->selected_column > 0) { model->selected_column--; } else { - model->selected_column = get_row_size(model->selected_row) - 1; + model->selected_column = + get_row_size(keyboards[model->selected_keyboard], model->selected_row) - 1; } } static void wifi_text_input_handle_right(WIFI_TextInput* wifi_text_input, WIFI_TextInputModel* model) { UNUSED(wifi_text_input); - if(model->selected_column < get_row_size(model->selected_row) - 1) { + if(model->cursor_select) { + model->cursor_pos = CLAMP(model->cursor_pos + 1, strlen(model->text_buffer), 0u); + } else if( + model->selected_column < + get_row_size(keyboards[model->selected_keyboard], model->selected_row) - 1) { model->selected_column++; } else { model->selected_column = 0; @@ -359,35 +446,49 @@ static void static void wifi_text_input_handle_ok( WIFI_TextInput* wifi_text_input, WIFI_TextInputModel* model, - bool shift) { + InputType type) { + if(model->cursor_select) return; + bool shift = type == InputTypeLong; + bool repeat = type == InputTypeRepeat; char selected = get_selected_char(model); - uint8_t text_length = strlen(model->text_buffer); - - if(shift) { - selected = char_to_uppercase(selected); - } + size_t text_length = strlen(model->text_buffer); if(selected == ENTER_KEY) { if(model->validator_callback && (!model->validator_callback( model->text_buffer, model->validator_text, model->validator_callback_context))) { - model->valadator_message_visible = true; + model->validator_message_visible = true; furi_timer_start(wifi_text_input->timer, furi_kernel_get_tick_frequency() * 4); - } else if(model->callback != 0 && text_length > 0) { + } else if(model->callback != 0 && text_length >= model->minimum_length) { model->callback(model->callback_context); } - } else if(selected == BACKSPACE_KEY) { - wifi_text_input_backspace_cb(model); + } else if(selected == SWITCH_KEYBOARD_KEY) { + switch_keyboard(model); } else { - if(model->clear_default_text) { - text_length = 0; - } - if(text_length < (model->text_buffer_size - 1)) { - model->text_buffer[text_length] = selected; - model->text_buffer[text_length + 1] = 0; + if(selected == BACKSPACE_KEY) { + wifi_text_input_backspace_cb(model); + } else if(!repeat) { + if(model->clear_default_text) { + text_length = 0; + } + if(text_length < (model->text_buffer_size - 1)) { + if(shift != (text_length == 0)) { + selected = char_to_uppercase(selected); + } + if(model->clear_default_text) { + model->text_buffer[0] = selected; + model->text_buffer[1] = '\0'; + model->cursor_pos = 1; + } else { + char* move = model->text_buffer + model->cursor_pos; + memmove(move + 1, move, strlen(move) + 1); + model->text_buffer[model->cursor_pos] = selected; + model->cursor_pos++; + } + } } + model->clear_default_text = false; } - model->clear_default_text = false; } static bool wifi_text_input_view_input_callback(InputEvent* event, void* context) { @@ -400,8 +501,8 @@ static bool wifi_text_input_view_input_callback(InputEvent* event, void* context WIFI_TextInputModel* model = view_get_model(wifi_text_input->view); if((!(event->type == InputTypePress) && !(event->type == InputTypeRelease)) && - model->valadator_message_visible) { - model->valadator_message_visible = false; + model->validator_message_visible) { + model->validator_message_visible = false; consumed = true; } else if(event->type == InputTypeShort) { consumed = true; @@ -419,7 +520,7 @@ static bool wifi_text_input_view_input_callback(InputEvent* event, void* context wifi_text_input_handle_right(wifi_text_input, model); break; case InputKeyOk: - wifi_text_input_handle_ok(wifi_text_input, model, false); + wifi_text_input_handle_ok(wifi_text_input, model, event->type); break; default: consumed = false; @@ -441,7 +542,7 @@ static bool wifi_text_input_view_input_callback(InputEvent* event, void* context wifi_text_input_handle_right(wifi_text_input, model); break; case InputKeyOk: - wifi_text_input_handle_ok(wifi_text_input, model, true); + wifi_text_input_handle_ok(wifi_text_input, model, event->type); break; case InputKeyBack: wifi_text_input_backspace_cb(model); @@ -465,6 +566,9 @@ static bool wifi_text_input_view_input_callback(InputEvent* event, void* context case InputKeyRight: wifi_text_input_handle_right(wifi_text_input, model); break; + case InputKeyOk: + wifi_text_input_handle_ok(wifi_text_input, model, event->type); + break; case InputKeyBack: wifi_text_input_backspace_cb(model); break; @@ -487,7 +591,7 @@ void wifi_text_input_timer_callback(void* context) { with_view_model( wifi_text_input->view, WIFI_TextInputModel * model, - { model->valadator_message_visible = false; }, + { model->validator_message_visible = false; }, true); } @@ -505,7 +609,12 @@ WIFI_TextInput* wifi_text_input_alloc() { with_view_model( wifi_text_input->view, WIFI_TextInputModel * model, - { model->validator_text = furi_string_alloc(); }, + { + model->validator_text = furi_string_alloc(); + model->minimum_length = 1; + model->cursor_pos = 0; + model->cursor_select = false; + }, false); wifi_text_input_reset(wifi_text_input); @@ -537,11 +646,14 @@ void wifi_text_input_reset(WIFI_TextInput* wifi_text_input) { wifi_text_input->view, WIFI_TextInputModel * model, { - model->text_buffer_size = 0; model->header = ""; model->selected_row = 0; model->selected_column = 0; + model->selected_keyboard = 0; + model->minimum_length = 1; model->clear_default_text = false; + model->cursor_pos = 0; + model->cursor_select = false; model->text_buffer = NULL; model->text_buffer_size = 0; model->callback = NULL; @@ -549,7 +661,7 @@ void wifi_text_input_reset(WIFI_TextInput* wifi_text_input) { model->validator_callback = NULL; model->validator_callback_context = NULL; furi_string_reset(model->validator_text); - model->valadator_message_visible = false; + model->validator_message_visible = false; }, true); } @@ -575,15 +687,28 @@ void wifi_text_input_set_result_callback( model->text_buffer = text_buffer; model->text_buffer_size = text_buffer_size; model->clear_default_text = clear_default_text; + model->cursor_select = false; if(text_buffer && text_buffer[0] != '\0') { + model->cursor_pos = strlen(text_buffer); // Set focus on Save model->selected_row = 2; - model->selected_column = 8; + model->selected_column = 9; + model->selected_keyboard = 0; + } else { + model->cursor_pos = 0; } }, true); } +void wifi_text_input_set_minimum_length(WIFI_TextInput* wifi_text_input, size_t minimum_length) { + with_view_model( + wifi_text_input->view, + WIFI_TextInputModel * model, + { model->minimum_length = minimum_length; }, + true); +} + void wifi_text_input_set_validator( WIFI_TextInput* wifi_text_input, WIFI_TextInputValidatorCallback callback, diff --git a/applications/external/wifi_marauder_companion/wifi_marauder_text_input.h b/applications/external/wifi_marauder_companion/wifi_marauder_text_input.h index b6b1f7bdfd..f5efe9234b 100644 --- a/applications/external/wifi_marauder_companion/wifi_marauder_text_input.h +++ b/applications/external/wifi_marauder_companion/wifi_marauder_text_input.h @@ -22,27 +22,27 @@ WIFI_TextInput* wifi_text_input_alloc(); /** Deinitialize and free text input * - * @param wifi_text_input WIFI_TextInput instance + * @param text_input WIFI_TextInput instance */ -void wifi_text_input_free(WIFI_TextInput* wifi_text_input); +void wifi_text_input_free(WIFI_TextInput* text_input); /** Clean text input view Note: this function does not free memory * - * @param wifi_text_input Text input instance + * @param text_input Text input instance */ -void wifi_text_input_reset(WIFI_TextInput* wifi_text_input); +void wifi_text_input_reset(WIFI_TextInput* text_input); /** Get text input view * - * @param wifi_text_input WIFI_TextInput instance + * @param text_input WIFI_TextInput instance * * @return View instance that can be used for embedding */ -View* wifi_text_input_get_view(WIFI_TextInput* wifi_text_input); +View* wifi_text_input_get_view(WIFI_TextInput* text_input); /** Set text input result callback * - * @param wifi_text_input WIFI_TextInput instance + * @param text_input WIFI_TextInput instance * @param callback callback fn * @param callback_context callback context * @param text_buffer pointer to YOUR text buffer, that we going @@ -53,7 +53,7 @@ View* wifi_text_input_get_view(WIFI_TextInput* wifi_text_input); * event */ void wifi_text_input_set_result_callback( - WIFI_TextInput* wifi_text_input, + WIFI_TextInput* text_input, WIFI_TextInputCallback callback, void* callback_context, char* text_buffer, @@ -61,22 +61,23 @@ void wifi_text_input_set_result_callback( bool clear_default_text); void wifi_text_input_set_validator( - WIFI_TextInput* wifi_text_input, + WIFI_TextInput* text_input, WIFI_TextInputValidatorCallback callback, void* callback_context); -WIFI_TextInputValidatorCallback - wifi_text_input_get_validator_callback(WIFI_TextInput* wifi_text_input); +void wifi_text_input_set_minimum_length(WIFI_TextInput* text_input, size_t minimum_length); -void* wifi_text_input_get_validator_callback_context(WIFI_TextInput* wifi_text_input); +WIFI_TextInputValidatorCallback wifi_text_input_get_validator_callback(WIFI_TextInput* text_input); + +void* wifi_text_input_get_validator_callback_context(WIFI_TextInput* text_input); /** Set text input header text * - * @param wifi_text_input WIFI_TextInput instance + * @param text_input WIFI_TextInput instance * @param text text to be shown */ -void wifi_text_input_set_header_text(WIFI_TextInput* wifi_text_input, const char* text); +void wifi_text_input_set_header_text(WIFI_TextInput* text_input, const char* text); #ifdef __cplusplus } -#endif +#endif \ No newline at end of file From 8ee959e1afc2e08b1f729cc4799a6f341ff61062 Mon Sep 17 00:00:00 2001 From: nminaylov Date: Fri, 19 May 2023 18:14:22 +0300 Subject: [PATCH 28/92] USB HID report timeout --- firmware/targets/f7/furi_hal/furi_hal_usb_hid.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/firmware/targets/f7/furi_hal/furi_hal_usb_hid.c b/firmware/targets/f7/furi_hal/furi_hal_usb_hid.c index d27613410b..334aa01026 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_usb_hid.c +++ b/firmware/targets/f7/furi_hal/furi_hal_usb_hid.c @@ -436,7 +436,11 @@ static bool hid_send_report(uint8_t report_id) { if((hid_semaphore == NULL) || (hid_connected == false)) return false; if((boot_protocol == true) && (report_id != ReportIdKeyboard)) return false; - furi_check(furi_semaphore_acquire(hid_semaphore, FuriWaitForever) == FuriStatusOk); + FuriStatus status = furi_semaphore_acquire(hid_semaphore, HID_INTERVAL * 2); + if(status == FuriStatusErrorTimeout) { + return false; + } + furi_check(status == FuriStatusOk); if(hid_connected == false) { return false; } From 2bda0820bfb16c4397b4a7e99f0481ef30614936 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sat, 20 May 2023 09:38:44 +0300 Subject: [PATCH 29/92] SubGHz App: alloc balance --- applications/main/subghz/scenes/subghz_scene_decode_raw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_decode_raw.c b/applications/main/subghz/scenes/subghz_scene_decode_raw.c index e88da3749f..102965df5b 100644 --- a/applications/main/subghz/scenes/subghz_scene_decode_raw.c +++ b/applications/main/subghz/scenes/subghz_scene_decode_raw.c @@ -179,11 +179,12 @@ void subghz_scene_decode_raw_on_enter(void* context) { furi_string_get_cstr(item_time), subghz_history_get_type_protocol(subghz->history, i)); } - furi_string_free(item_name); - furi_string_free(item_time); subghz_view_receiver_set_idx_menu(subghz->subghz_receiver, subghz->idx_menu_chosen); } + furi_string_free(item_name); + furi_string_free(item_time); + subghz_scene_receiver_update_statusbar(subghz); view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdReceiver); From d949b010d863c25f8c81f5b1b956e263b61a93e1 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 19 May 2023 23:21:18 +0300 Subject: [PATCH 30/92] Loading States & fix label length --- .../main/subghz_remote/helpers/subrem_types.h | 15 +++++ .../scenes/subrem_scene_openmapfile.c | 2 +- .../subghz_remote/scenes/subrem_scene_start.c | 6 +- .../main/subghz_remote/subghz_remote_app_i.c | 58 ++++++++++++------- .../main/subghz_remote/subghz_remote_app_i.h | 3 +- .../main/subghz_remote/views/remote.c | 2 +- 6 files changed, 60 insertions(+), 26 deletions(-) diff --git a/applications/main/subghz_remote/helpers/subrem_types.h b/applications/main/subghz_remote/helpers/subrem_types.h index 1b99aac6d2..13b42897f6 100644 --- a/applications/main/subghz_remote/helpers/subrem_types.h +++ b/applications/main/subghz_remote/helpers/subrem_types.h @@ -25,8 +25,23 @@ typedef enum { SubRemViewIDRemote, } SubRemViewID; +typedef enum { + SubRemLoadSubStateNotSet, + SubRemLoadSubStatePreloaded, + SubRemLoadSubStateError, + SubRemLoadSubStateErrorNoFile, + SubRemLoadSubStateErrorFreq, + SubRemLoadSubStateErrorMod, + SubRemLoadSubStateErrorProtocol, + SubRemLoadSubStateOK, +} SubRemLoadSubState; + typedef enum { SubRemLoadMapStateBack = 0, SubRemLoadMapStateError, + SubRemLoadMapStateErrorOpenError, + SubRemLoadMapStateErrorStorage, + SubRemLoadMapStateErrorBrokenFile, + SubRemLoadMapStateNotAllOK, SubRemLoadMapStateOK, } SubRemLoadMapState; \ No newline at end of file diff --git a/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c b/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c index 3391845e12..ea5c14a0a5 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c @@ -18,7 +18,7 @@ void subrem_scene_openmapfile_on_enter(void* context) { dialog_message_free(message); #endif } - if(load_state == SubRemLoadMapStateOK) { + if(load_state == SubRemLoadMapStateOK || load_state == SubRemLoadMapStateNotAllOK) { scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); } else { // TODO: Map Preset Reset diff --git a/applications/main/subghz_remote/scenes/subrem_scene_start.c b/applications/main/subghz_remote/scenes/subrem_scene_start.c index 962eda54ca..a4bfa50475 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_start.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_start.c @@ -34,8 +34,10 @@ void subrem_scene_start_on_enter(void* context) { // subrem_scene_start_submenu_callback, // app); - submenu_set_selected_item( - submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); + // TODO: set scene state in subrem alloc + // submenu_set_selected_item( + // submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); + submenu_set_selected_item(submenu, SubmenuIndexSubRemOpenMapFile); view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewSubmenu); } diff --git a/applications/main/subghz_remote/subghz_remote_app_i.c b/applications/main/subghz_remote/subghz_remote_app_i.c index 171618a5f8..349fb87cdb 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.c +++ b/applications/main/subghz_remote/subghz_remote_app_i.c @@ -51,6 +51,7 @@ SubRemSubFilePreset* subrem_sub_file_preset_alloc() { sub_preset->label = furi_string_alloc_set_str("N/A"); sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; return sub_preset; } @@ -77,6 +78,7 @@ static void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { stream_clean(fff_data_stream); sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; } void subrem_map_preset_reset(SubGhzRemoteApp* app) { @@ -108,6 +110,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data #endif path_extract_filename(sub_preset->file_path, sub_preset->label, true); } else { + // Preload seccesful FURI_LOG_I( TAG, "%-5s: %s %s", @@ -115,6 +118,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data furi_string_get_cstr(sub_preset->label), furi_string_get_cstr(sub_preset->file_path)); ret = true; + sub_preset->load_state = SubRemLoadSubStatePreloaded; } flipper_format_rewind(fff_data_file); } @@ -268,21 +272,25 @@ bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { return false; } -static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { +static SubRemLoadMapState + subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); FuriString* temp_str = furi_string_alloc(); uint32_t temp_data32; - bool ret = false; - bool sub_preset_loaded = false; + bool all_loaded = true; + SubRemLoadMapState ret = SubRemLoadMapStateErrorBrokenFile; + SubRemLoadSubState sub_preset_loaded; SubRemSubFilePreset* sub_preset; uint32_t repeat = 200; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { sub_preset = app->subs_preset[i]; - sub_preset_loaded = false; if(furi_string_empty(sub_preset->file_path)) { // FURI_LOG_I(TAG, "Empty file path"); continue; } + + sub_preset_loaded = SubRemLoadSubStateErrorNoFile; + repeat = 200; do { if(!flipper_format_file_open_existing( @@ -305,6 +313,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat } //Load frequency + sub_preset_loaded = SubRemLoadSubStateErrorFreq; if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); sub_preset->freq_preset.frequency = @@ -317,6 +326,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat } //Load preset + sub_preset_loaded = SubRemLoadSubStateErrorMod; if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { FURI_LOG_E(TAG, "Missing Preset"); break; @@ -329,6 +339,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat } //Load protocol + sub_preset_loaded = SubRemLoadSubStateErrorProtocol; if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { FURI_LOG_E(TAG, "Missing Protocol"); break; @@ -375,8 +386,9 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat break; } - sub_preset_loaded = true; - ret |= true; + sub_preset_loaded = SubRemLoadSubStateOK; + ret = SubRemLoadMapStateNotAllOK; + #if FURI_DEBUG FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); #endif @@ -385,9 +397,15 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat // TODO: // Load file state logic // Label depending on the state + // Move to remote scene - if(!sub_preset_loaded) { + if(sub_preset_loaded != SubRemLoadSubStateOK) { furi_string_set_str(sub_preset->label, "N/A"); + all_loaded = false; + } + + if(ret != SubRemLoadMapStateErrorBrokenFile && all_loaded) { + ret = SubRemLoadMapStateOK; } flipper_format_file_close(fff_data_file); @@ -397,7 +415,7 @@ static bool subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_dat return ret; } -bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { +SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { furi_assert(app); furi_assert(file_path); #if FURI_DEBUG @@ -405,7 +423,7 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { #endif Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); - bool ret = false; + SubRemLoadMapState ret = SubRemLoadMapStateErrorOpenError; #if FURI_DEBUG FURI_LOG_I(TAG, "Open Map File.."); #endif @@ -413,20 +431,23 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { if(!flipper_format_file_open_existing(fff_data_file, file_path)) { FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); + ret = SubRemLoadMapStateErrorOpenError; } else { if(!subrem_map_preset_load(app, fff_data_file)) { FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); // ret = // error for popup - } else if( - (flipper_format_file_close(fff_data_file)) && - (subrem_map_preset_check(app, fff_data_file))) { - FURI_LOG_I(TAG, "Load Map File Seccesful"); - ret = true; + } else if(!flipper_format_file_close(fff_data_file)) { + ret = SubRemLoadMapStateErrorOpenError; + } else { + ret = subrem_map_preset_check(app, fff_data_file); } } - // TODO: Popup for error or return error type - if(!ret) { + if(ret == SubRemLoadMapStateOK) { + FURI_LOG_I(TAG, "Load Map File Seccesful"); + } else if(ret == SubRemLoadMapStateNotAllOK) { + FURI_LOG_I(TAG, "Load Map File Seccesful [Not all files]"); + } else { FURI_LOG_E(TAG, "Broken Map File"); } @@ -434,7 +455,6 @@ bool subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path) { flipper_format_free(fff_data_file); furi_record_close(RECORD_STORAGE); - return ret; } @@ -450,10 +470,8 @@ SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) { // Input events and views are managed by file_select if(!dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options)) { - } else if(subrem_map_file_load(app, furi_string_get_cstr(app->file_path))) { - ret = SubRemLoadMapStateOK; } else { - ret = SubRemLoadMapStateError; + ret = subrem_map_file_load(app, furi_string_get_cstr(app->file_path)); } furi_string_free(file_path); diff --git a/applications/main/subghz_remote/subghz_remote_app_i.h b/applications/main/subghz_remote/subghz_remote_app_i.h index 1cbdbd5cd0..40d70411ab 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.h +++ b/applications/main/subghz_remote/subghz_remote_app_i.h @@ -42,6 +42,7 @@ typedef struct { FuriString* protocaol_name; FuriString* label; SubGhzProtocolType type; + SubRemLoadSubState load_state; } SubRemSubFilePreset; SubRemSubFilePreset* subrem_sub_file_preset_alloc(); @@ -70,8 +71,6 @@ typedef struct { bool tx_running; uint8_t chusen_sub; - - // TODO: LoadFileError } SubGhzRemoteApp; SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app); diff --git a/applications/main/subghz_remote/views/remote.c b/applications/main/subghz_remote/views/remote.c index 85c63568ea..1f867cd0b6 100644 --- a/applications/main/subghz_remote/views/remote.c +++ b/applications/main/subghz_remote/views/remote.c @@ -4,7 +4,7 @@ #include #include -#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 16 +#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 12 struct SubRemViewRemote { View* view; From 47b1cadbb66f00cfdb2f9d7fd63896fa2ca1b20f Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sat, 20 May 2023 15:05:26 +0300 Subject: [PATCH 31/92] fix alloc balance --- applications/main/subghz_remote/subghz_remote_app.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index 0b3f645ab8..b957fb8bcb 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -42,6 +42,7 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { // View Dispatcher app->view_dispatcher = view_dispatcher_alloc(); + app->scene_manager = scene_manager_alloc(&subrem_scene_handlers, app); view_dispatcher_enable_queue(app->view_dispatcher); @@ -127,6 +128,9 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDRemote); subrem_view_remote_free(app->subrem_remote_view); + scene_manager_free(app->scene_manager); + view_dispatcher_free(app->view_dispatcher); + subghz_receiver_free(app->receiver); subghz_environment_free(app->environment); subghz_setting_free(app->setting); From b11b0a4911c7fbde841197562bea464b52f47eba Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sat, 20 May 2023 15:05:26 +0300 Subject: [PATCH 32/92] udp --- applications/external/subghz_remote_new/subghz_remote_app.c | 4 ++++ applications/external/subghz_remote_new/subghz_remote_app_i.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_new/subghz_remote_app.c index 0b3f645ab8..b957fb8bcb 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app.c +++ b/applications/external/subghz_remote_new/subghz_remote_app.c @@ -42,6 +42,7 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { // View Dispatcher app->view_dispatcher = view_dispatcher_alloc(); + app->scene_manager = scene_manager_alloc(&subrem_scene_handlers, app); view_dispatcher_enable_queue(app->view_dispatcher); @@ -127,6 +128,9 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDRemote); subrem_view_remote_free(app->subrem_remote_view); + scene_manager_free(app->scene_manager); + view_dispatcher_free(app->view_dispatcher); + subghz_receiver_free(app->receiver); subghz_environment_free(app->environment); subghz_setting_free(app->setting); diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index 4f5065b077..adc2219419 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -288,7 +288,9 @@ static SubRemLoadMapState // FURI_LOG_I(TAG, "Empty file path"); continue; } + sub_preset_loaded = SubRemLoadSubStateErrorNoFile; + repeat = 200; do { if(!flipper_format_file_open_existing( @@ -386,6 +388,7 @@ static SubRemLoadMapState sub_preset_loaded = SubRemLoadSubStateOK; ret = SubRemLoadMapStateNotAllOK; + #if FURI_DEBUG FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); #endif From 26bcebd5758176c969b49dd17fbefcbf6248a58f Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sun, 21 May 2023 10:29:58 +0300 Subject: [PATCH 33/92] move part of preset --- .../subghz_remote/helpers/subrem_presets.c | 40 ++ .../subghz_remote/helpers/subrem_presets.h | 27 ++ .../scenes/subrem_scene_remote.c | 12 +- .../main/subghz_remote/subghz_remote_app.c | 6 +- .../main/subghz_remote/subghz_remote_app_i.c | 345 ++++++++---------- .../main/subghz_remote/subghz_remote_app_i.h | 28 +- 6 files changed, 237 insertions(+), 221 deletions(-) create mode 100644 applications/main/subghz_remote/helpers/subrem_presets.c create mode 100644 applications/main/subghz_remote/helpers/subrem_presets.h diff --git a/applications/main/subghz_remote/helpers/subrem_presets.c b/applications/main/subghz_remote/helpers/subrem_presets.c new file mode 100644 index 0000000000..03e497198b --- /dev/null +++ b/applications/main/subghz_remote/helpers/subrem_presets.c @@ -0,0 +1,40 @@ +#include "subrem_presets.h" + +SubRemSubFilePreset* subrem_sub_file_preset_alloc() { + SubRemSubFilePreset* sub_preset = malloc(sizeof(SubRemSubFilePreset)); + + sub_preset->fff_data = flipper_format_string_alloc(); + sub_preset->file_path = furi_string_alloc(); + sub_preset->protocaol_name = furi_string_alloc(); + sub_preset->label = furi_string_alloc_set_str("N/A"); + + sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; + + return sub_preset; +} + +void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { + furi_assert(sub_preset); + + furi_string_free(sub_preset->label); + furi_string_free(sub_preset->protocaol_name); + furi_string_free(sub_preset->file_path); + flipper_format_free(sub_preset->fff_data); + + free(sub_preset); +} + +void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { + furi_assert(sub_preset); + + furi_string_set_str(sub_preset->label, "N/A"); + furi_string_reset(sub_preset->protocaol_name); + furi_string_reset(sub_preset->file_path); + + Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); + stream_clean(fff_data_stream); + + sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; +} diff --git a/applications/main/subghz_remote/helpers/subrem_presets.h b/applications/main/subghz_remote/helpers/subrem_presets.h new file mode 100644 index 0000000000..60eedad576 --- /dev/null +++ b/applications/main/subghz_remote/helpers/subrem_presets.h @@ -0,0 +1,27 @@ +#pragma once + +#include "subrem_types.h" +#include +#include + +typedef struct { + uint32_t frequency; + uint8_t* data; +} FreqPreset; + +// Sub File preset +typedef struct { + FlipperFormat* fff_data; + FreqPreset freq_preset; + FuriString* file_path; + FuriString* protocaol_name; + FuriString* label; + SubGhzProtocolType type; + SubRemLoadSubState load_state; +} SubRemSubFilePreset; + +SubRemSubFilePreset* subrem_sub_file_preset_alloc(); + +void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset); + +void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset); diff --git a/applications/main/subghz_remote/scenes/subrem_scene_remote.c b/applications/main/subghz_remote/scenes/subrem_scene_remote.c index c245832336..1b8dbc4717 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_remote.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_remote.c @@ -41,11 +41,11 @@ static bool subrem_scene_remote_update_data_show(void* context) { subrem_view_remote_add_data_to_show( app->subrem_remote_view, - furi_string_get_cstr(app->subs_preset[0]->label), - furi_string_get_cstr(app->subs_preset[1]->label), - furi_string_get_cstr(app->subs_preset[2]->label), - furi_string_get_cstr(app->subs_preset[3]->label), - furi_string_get_cstr(app->subs_preset[4]->label)); + furi_string_get_cstr(app->map_preset->subs_preset[0]->label), + furi_string_get_cstr(app->map_preset->subs_preset[1]->label), + furi_string_get_cstr(app->map_preset->subs_preset[2]->label), + furi_string_get_cstr(app->map_preset->subs_preset[3]->label), + furi_string_get_cstr(app->map_preset->subs_preset[4]->label)); return ret; } @@ -85,7 +85,7 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateLoading); if(subrem_tx_start_sub( app, - app->subs_preset[app->chusen_sub], + app->map_preset->subs_preset[app->chusen_sub], subrem_scene_remote_raw_callback_end_tx)) { subrem_view_remote_set_presed_btn(app->subrem_remote_view, app->chusen_sub); subrem_view_remote_set_state( diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index b957fb8bcb..4f9138e2aa 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -74,8 +74,9 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { SubRemViewIDRemote, subrem_view_remote_get_view(app->subrem_remote_view)); + app->map_preset = malloc(sizeof(SubRemMapPreset)); for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - app->subs_preset[i] = subrem_sub_file_preset_alloc(); + app->map_preset->subs_preset[i] = subrem_sub_file_preset_alloc(); } app->setting = subghz_setting_alloc(); @@ -136,8 +137,9 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { subghz_setting_free(app->setting); for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - subrem_sub_file_preset_free(app->subs_preset[i]); + subrem_sub_file_preset_free(app->map_preset->subs_preset[i]); } + free(app->map_preset); // Notifications furi_record_close(RECORD_NOTIFICATION); diff --git a/applications/main/subghz_remote/subghz_remote_app_i.c b/applications/main/subghz_remote/subghz_remote_app_i.c index 349fb87cdb..9c35a0e036 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.c +++ b/applications/main/subghz_remote/subghz_remote_app_i.c @@ -42,50 +42,11 @@ static bool return true; } -SubRemSubFilePreset* subrem_sub_file_preset_alloc() { - SubRemSubFilePreset* sub_preset = malloc(sizeof(SubRemSubFilePreset)); - - sub_preset->fff_data = flipper_format_string_alloc(); - sub_preset->file_path = furi_string_alloc(); - sub_preset->protocaol_name = furi_string_alloc(); - sub_preset->label = furi_string_alloc_set_str("N/A"); - - sub_preset->type = SubGhzProtocolTypeUnknown; - sub_preset->load_state = SubRemLoadSubStateNotSet; - - return sub_preset; -} - -void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { - furi_assert(sub_preset); - - furi_string_free(sub_preset->label); - furi_string_free(sub_preset->protocaol_name); - furi_string_free(sub_preset->file_path); - flipper_format_free(sub_preset->fff_data); - - free(sub_preset); -} - -static void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { - furi_assert(sub_preset); - - furi_string_set_str(sub_preset->label, "N/A"); - furi_string_reset(sub_preset->protocaol_name); - furi_string_reset(sub_preset->file_path); - - Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); - stream_clean(fff_data_stream); - - sub_preset->type = SubGhzProtocolTypeUnknown; - sub_preset->load_state = SubRemLoadSubStateNotSet; -} - -void subrem_map_preset_reset(SubGhzRemoteApp* app) { - furi_assert(app); +void subrem_map_preset_reset(SubRemMapPreset* map_preset) { + furi_assert(map_preset); for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - subrem_sub_file_preset_reset(app->subs_preset[i]); + subrem_sub_file_preset_reset(map_preset->subs_preset[i]); } } @@ -94,7 +55,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data bool ret = false; SubRemSubFilePreset* sub_preset; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - sub_preset = app->subs_preset[i]; + sub_preset = app->map_preset->subs_preset[i]; if(!flipper_format_read_string( fff_data_file, map_file_labels[i][0], sub_preset->file_path)) { #if FURI_DEBUG @@ -125,153 +86,6 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data return ret; } -bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { - furi_assert(flipper_format); - furi_assert(dev_file_name); - - Storage* storage = furi_record_open(RECORD_STORAGE); - Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); - - bool saved = false; - uint32_t repeat = 200; - FuriString* file_dir = furi_string_alloc(); - - path_extract_dirname(dev_file_name, file_dir); - do { - // removing additional fields - flipper_format_delete_key(flipper_format, "Repeat"); - // flipper_format_delete_key(flipper_format, "Manufacture"); - - if(!storage_simply_remove(storage, dev_file_name)) { - break; - } - - //ToDo check Write - stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); - stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); - - if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { - FURI_LOG_E(TAG, "Unable Repeat"); - break; - } - - saved = true; - } while(0); - - furi_string_free(file_dir); - furi_record_close(RECORD_STORAGE); - return saved; -} - -bool subrem_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback) { - furi_assert(app); - furi_assert(sub_preset); - bool ret = false; - - subrem_tx_stop_sub(app, true); - - if(sub_preset->type == SubGhzProtocolTypeUnknown) { - return false; - } - - FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); - - subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); - keeloq_reset_original_btn(); - subghz_custom_btns_reset(); - - do { - flipper_format_rewind(sub_preset->fff_data); // - - app->transmitter = subghz_transmitter_alloc_init( - app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); - - if(app->transmitter) { - if(subghz_transmitter_deserialize(app->transmitter, sub_preset->fff_data) != - SubGhzProtocolStatusOk) { - FURI_LOG_E(TAG, "Deserialize error!"); - break; - } - furi_hal_subghz_reset(); - furi_hal_subghz_idle(); - furi_hal_subghz_load_custom_preset(sub_preset->freq_preset.data); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); - - furi_hal_subghz_idle(); - - furi_hal_subghz_set_frequency_and_path(sub_preset->freq_preset.frequency); - furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - - if(!furi_hal_subghz_tx()) { - FURI_LOG_E(TAG, "Sending not allowed"); - break; - } - - if(sub_preset->type == SubGhzProtocolTypeRAW) { - subghz_protocol_raw_file_encoder_worker_set_callback_end( - (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( - app->transmitter), - callback, - app); - } - - furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); - - ret = true; - } - } while(false); - - app->tx_running = ret; - - return ret; -} - -static void subghz_tx_stop(SubGhzRemoteApp* app) { - furi_assert(app); - - //Stop TX - furi_hal_subghz_stop_async_tx(); - - subghz_transmitter_stop(app->transmitter); - subghz_transmitter_free(app->transmitter); - furi_hal_subghz_idle(); -} - -bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { - furi_assert(app); - SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; - - if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) { - // SubRemSubKeyTypeRawKey)) { - if(app->tx_running) { - subghz_tx_stop(app); - - if(sub_preset->type == SubGhzProtocolTypeDynamic) { - subrem_save_protocol_to_file( - sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); - - keeloq_reset_mfname(); - keeloq_reset_kl_type(); - keeloq_reset_original_btn(); - subghz_custom_btns_reset(); - star_line_reset_mfname(); - star_line_reset_kl_type(); - } - - app->tx_running = false; - return true; - } - } - - return false; -} - static SubRemLoadMapState subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); @@ -283,7 +97,7 @@ static SubRemLoadMapState SubRemSubFilePreset* sub_preset; uint32_t repeat = 200; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - sub_preset = app->subs_preset[i]; + sub_preset = app->map_preset->subs_preset[i]; if(furi_string_empty(sub_preset->file_path)) { // FURI_LOG_I(TAG, "Empty file path"); continue; @@ -427,7 +241,7 @@ SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_p #if FURI_DEBUG FURI_LOG_I(TAG, "Open Map File.."); #endif - subrem_map_preset_reset(app); + subrem_map_preset_reset(app->map_preset); if(!flipper_format_file_open_existing(fff_data_file, file_path)) { FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); @@ -458,6 +272,153 @@ SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_p return ret; } +bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { + furi_assert(flipper_format); + furi_assert(dev_file_name); + + Storage* storage = furi_record_open(RECORD_STORAGE); + Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); + + bool saved = false; + uint32_t repeat = 200; + FuriString* file_dir = furi_string_alloc(); + + path_extract_dirname(dev_file_name, file_dir); + do { + // removing additional fields + flipper_format_delete_key(flipper_format, "Repeat"); + // flipper_format_delete_key(flipper_format, "Manufacture"); + + if(!storage_simply_remove(storage, dev_file_name)) { + break; + } + + //ToDo check Write + stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); + stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); + + if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + + saved = true; + } while(0); + + furi_string_free(file_dir); + furi_record_close(RECORD_STORAGE); + return saved; +} + +bool subrem_tx_start_sub( + SubGhzRemoteApp* app, + SubRemSubFilePreset* sub_preset, + SubGhzProtocolEncoderRAWCallbackEnd callback) { + furi_assert(app); + furi_assert(sub_preset); + bool ret = false; + + subrem_tx_stop_sub(app, true); + + if(sub_preset->type == SubGhzProtocolTypeUnknown) { + return false; + } + + FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); + + subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); + keeloq_reset_original_btn(); + subghz_custom_btns_reset(); + + do { + flipper_format_rewind(sub_preset->fff_data); // + + app->transmitter = subghz_transmitter_alloc_init( + app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); + + if(app->transmitter) { + if(subghz_transmitter_deserialize(app->transmitter, sub_preset->fff_data) != + SubGhzProtocolStatusOk) { + FURI_LOG_E(TAG, "Deserialize error!"); + break; + } + furi_hal_subghz_reset(); + furi_hal_subghz_idle(); + furi_hal_subghz_load_custom_preset(sub_preset->freq_preset.data); + furi_hal_gpio_init( + furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); + + furi_hal_subghz_idle(); + + furi_hal_subghz_set_frequency_and_path(sub_preset->freq_preset.frequency); + furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); + furi_hal_gpio_init( + furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); + + if(!furi_hal_subghz_tx()) { + FURI_LOG_E(TAG, "Sending not allowed"); + break; + } + + if(sub_preset->type == SubGhzProtocolTypeRAW) { + subghz_protocol_raw_file_encoder_worker_set_callback_end( + (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( + app->transmitter), + callback, + app); + } + + furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); + + ret = true; + } + } while(false); + + app->tx_running = ret; + + return ret; +} + +static void subghz_tx_stop(SubGhzRemoteApp* app) { + furi_assert(app); + + //Stop TX + furi_hal_subghz_stop_async_tx(); + + subghz_transmitter_stop(app->transmitter); + subghz_transmitter_free(app->transmitter); + furi_hal_subghz_idle(); +} + +bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { + furi_assert(app); + SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub]; + + if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) { + // SubRemSubKeyTypeRawKey)) { + if(app->tx_running) { + subghz_tx_stop(app); + + if(sub_preset->type == SubGhzProtocolTypeDynamic) { + subrem_save_protocol_to_file( + sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); + + keeloq_reset_mfname(); + keeloq_reset_kl_type(); + keeloq_reset_original_btn(); + subghz_custom_btns_reset(); + star_line_reset_mfname(); + star_line_reset_kl_type(); + } + + app->tx_running = false; + return true; + } + } + + return false; +} + SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) { furi_assert(app); diff --git a/applications/main/subghz_remote/subghz_remote_app_i.h b/applications/main/subghz_remote/subghz_remote_app_i.h index 40d70411ab..5d34968cdc 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.h +++ b/applications/main/subghz_remote/subghz_remote_app_i.h @@ -1,6 +1,8 @@ #pragma once #include "helpers/subrem_types.h" +#include "helpers/subrem_presets.h" + #include #include "views/remote.h" @@ -30,25 +32,8 @@ #define SUBREM_MAX_LEN_NAME 64 typedef struct { - uint32_t frequency; - uint8_t* data; -} FreqPreset; - -// Sub File preset -typedef struct { - FlipperFormat* fff_data; - FreqPreset freq_preset; - FuriString* file_path; - FuriString* protocaol_name; - FuriString* label; - SubGhzProtocolType type; - SubRemLoadSubState load_state; -} SubRemSubFilePreset; - -SubRemSubFilePreset* subrem_sub_file_preset_alloc(); - -void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset); - + SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; +} SubRemMapPreset; typedef struct { Gui* gui; ViewDispatcher* view_dispatcher; @@ -56,12 +41,13 @@ typedef struct { NotificationApp* notifications; DialogsApp* dialogs; Submenu* submenu; + FuriString* file_path; - char file_name_tmp[SUBREM_MAX_LEN_NAME]; + // char file_name_tmp[SUBREM_MAX_LEN_NAME]; SubRemViewRemote* subrem_remote_view; - SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; + SubRemMapPreset* map_preset; SubGhzSetting* setting; SubGhzEnvironment* environment; From d7db7b8b6729a486d9db1239edcb78c9c7f72531 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 21 May 2023 20:18:09 +0300 Subject: [PATCH 34/92] fix builds for old pythons --- scripts/fbt/appmanifest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/fbt/appmanifest.py b/scripts/fbt/appmanifest.py index ed1654e366..eb265cee86 100644 --- a/scripts/fbt/appmanifest.py +++ b/scripts/fbt/appmanifest.py @@ -1,7 +1,7 @@ import os from dataclasses import dataclass, field from enum import Enum -from typing import Callable, List, Optional, Tuple +from typing import Callable, List, Optional, Tuple, Union class FlipperManifestException(Exception): @@ -56,7 +56,7 @@ class Library: # .fap-specific sources: List[str] = field(default_factory=lambda: ["*.c*"]) - fap_version: str | Tuple[int] = "0.1" + fap_version: Union[str, Tuple[int]] = "0.1" fap_icon: Optional[str] = None fap_libs: List[str] = field(default_factory=list) fap_category: str = "" From ef19fa9b51c3c6047a865ae8ba0db4f0c32df30f Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 21 May 2023 20:37:55 +0300 Subject: [PATCH 35/92] SubRemote: Migrate old files and make folder if not exist --- applications/main/subghz_remote/subghz_remote_app.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index 0b3f645ab8..75f9fe3dcc 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -23,6 +23,14 @@ static void subghz_remote_app_tick_event_callback(void* context) { SubGhzRemoteApp* subghz_remote_app_alloc() { SubGhzRemoteApp* app = malloc(sizeof(SubGhzRemoteApp)); + Storage* storage = furi_record_open(RECORD_STORAGE); + storage_common_migrate(storage, EXT_PATH("unirf"), SUBREM_APP_FOLDER); + + if(!storage_simply_mkdir(storage, SUBREM_APP_FOLDER)) { + //FURI_LOG_E(TAG, "Could not create folder %s", SUBREM_APP_FOLDER); + } + furi_record_close(RECORD_STORAGE); + // Enable power for External CC1101 if it is connected furi_hal_subghz_enable_ext_power(); // Auto switch to internal radio if external radio is not available From d9fc408d96b5d012966e5039dced6e9c613ea1a4 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 21 May 2023 20:50:38 +0300 Subject: [PATCH 36/92] fbt: Use union for old py (#2685) --- scripts/fbt/appmanifest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/fbt/appmanifest.py b/scripts/fbt/appmanifest.py index ed1654e366..eb265cee86 100644 --- a/scripts/fbt/appmanifest.py +++ b/scripts/fbt/appmanifest.py @@ -1,7 +1,7 @@ import os from dataclasses import dataclass, field from enum import Enum -from typing import Callable, List, Optional, Tuple +from typing import Callable, List, Optional, Tuple, Union class FlipperManifestException(Exception): @@ -56,7 +56,7 @@ class Library: # .fap-specific sources: List[str] = field(default_factory=lambda: ["*.c*"]) - fap_version: str | Tuple[int] = "0.1" + fap_version: Union[str, Tuple[int]] = "0.1" fap_icon: Optional[str] = None fap_libs: List[str] = field(default_factory=list) fap_category: str = "" From 311533a0ac4cd106c2a7c3f53c2a11bffb26328b Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sun, 21 May 2023 23:34:42 +0300 Subject: [PATCH 37/92] Using TxRx from subghz --- .../subghz_remote/helpers/subrem_presets.c | 139 +++++++ .../subghz_remote/helpers/subrem_presets.h | 13 +- .../main/subghz_remote/helpers/subrem_types.h | 2 +- .../scenes/subrem_scene_openmapfile.c | 3 +- .../scenes/subrem_scene_remote.c | 51 +-- .../main/subghz_remote/subghz_remote_app.c | 22 +- .../main/subghz_remote/subghz_remote_app_i.c | 342 +++++------------- .../main/subghz_remote/subghz_remote_app_i.h | 19 +- .../main/subghz_remote/views/remote.c | 36 +- .../main/subghz_remote/views/remote.h | 12 +- 10 files changed, 308 insertions(+), 331 deletions(-) diff --git a/applications/main/subghz_remote/helpers/subrem_presets.c b/applications/main/subghz_remote/helpers/subrem_presets.c index 03e497198b..9601aae6ce 100644 --- a/applications/main/subghz_remote/helpers/subrem_presets.c +++ b/applications/main/subghz_remote/helpers/subrem_presets.c @@ -1,5 +1,7 @@ #include "subrem_presets.h" +#define TAG "SubRemPresets" + SubRemSubFilePreset* subrem_sub_file_preset_alloc() { SubRemSubFilePreset* sub_preset = malloc(sizeof(SubRemSubFilePreset)); @@ -8,6 +10,8 @@ SubRemSubFilePreset* subrem_sub_file_preset_alloc() { sub_preset->protocaol_name = furi_string_alloc(); sub_preset->label = furi_string_alloc_set_str("N/A"); + sub_preset->freq_preset.name = furi_string_alloc(); + sub_preset->type = SubGhzProtocolTypeUnknown; sub_preset->load_state = SubRemLoadSubStateNotSet; @@ -22,6 +26,8 @@ void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { furi_string_free(sub_preset->file_path); flipper_format_free(sub_preset->fff_data); + furi_string_free(sub_preset->freq_preset.name); + free(sub_preset); } @@ -38,3 +44,136 @@ void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { sub_preset->type = SubGhzProtocolTypeUnknown; sub_preset->load_state = SubRemLoadSubStateNotSet; } + +SubRemLoadSubState subrem_sub_preset_load( + SubRemSubFilePreset* sub_preset, + SubGhzTxRx* txrx, + FlipperFormat* fff_data_file) { + furi_assert(sub_preset); + furi_assert(txrx); + furi_assert(fff_data_file); + + Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); + + SubRemLoadSubState ret; + FuriString* temp_str = furi_string_alloc(); + uint32_t temp_data32; + uint32_t repeat = 200; + + ret = SubRemLoadSubStateError; + + do { + stream_clean(fff_data_stream); + if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) { + FURI_LOG_E(TAG, "Missing or incorrect header"); + break; + } + + if(((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) || + (!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) && + temp_data32 == SUBGHZ_KEY_FILE_VERSION) { + } else { + FURI_LOG_E(TAG, "Type or version mismatch"); + break; + } + + SubGhzSetting* setting = subghz_txrx_get_setting(txrx); // txrx->setting; + + //Load frequency or using default from settings + ret = SubRemLoadSubStateErrorFreq; + if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { + FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); + sub_preset->freq_preset.frequency = subghz_setting_get_default_frequency(setting); + } else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { + FURI_LOG_E(TAG, "This frequency can only be used for RX"); + break; + } + sub_preset->freq_preset.frequency = temp_data32; + + //Load preset + ret = SubRemLoadSubStateErrorMod; + if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { + FURI_LOG_E(TAG, "Missing Preset"); + break; + } + + furi_string_set_str( + temp_str, subghz_txrx_get_preset_name(txrx, furi_string_get_cstr(temp_str))); + if(!strcmp(furi_string_get_cstr(temp_str), "")) { + break; + } + + if(!strcmp(furi_string_get_cstr(temp_str), "CUSTOM")) { + FURI_LOG_E(TAG, "CUSTOM preset is not supported"); + break; + // TODO Custom preset loading logic if need + // sub_preset->freq_preset.preset_index = + // subghz_setting_get_inx_preset_by_name(setting, furi_string_get_cstr(temp_str)); + } + + furi_string_set(sub_preset->freq_preset.name, temp_str); + + // Load protocol + ret = SubRemLoadSubStateErrorProtocol; + if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { + FURI_LOG_E(TAG, "Missing Protocol"); + break; + } + + FlipperFormat* fff_data = sub_preset->fff_data; + if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) { + //if RAW + subghz_protocol_raw_gen_fff_data( + fff_data, furi_string_get_cstr(sub_preset->file_path)); + } else { + stream_copy_full( + flipper_format_get_raw_stream(fff_data_file), + flipper_format_get_raw_stream(fff_data)); + } + + if(subghz_txrx_load_decoder_by_name_protocol(txrx, furi_string_get_cstr(temp_str))) { + SubGhzProtocolStatus status = + subghz_protocol_decoder_base_deserialize(subghz_txrx_get_decoder(txrx), fff_data); + if(status != SubGhzProtocolStatusOk) { + break; + } + } else { + FURI_LOG_E(TAG, "Protocol not found"); + break; + } + + const SubGhzProtocol* protocol = subghz_txrx_get_decoder(txrx)->protocol; + + if(protocol->flag & SubGhzProtocolFlag_Send) { + if((protocol->type == SubGhzProtocolTypeStatic) || + (protocol->type == SubGhzProtocolTypeDynamic) || + // TODO: BINRAW It probably works, but checks are needed. + // (protocol->type == SubGhzProtocolTypeBinRAW) || + (protocol->type == SubGhzProtocolTypeRAW)) { + sub_preset->type = protocol->type; + } else { + FURI_LOG_E(TAG, "Unsuported Protocol"); + break; + } + + furi_string_set(sub_preset->protocaol_name, temp_str); + } else { + FURI_LOG_E(TAG, "Protocol does not support transmission"); + break; + } + + if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + + ret = SubRemLoadSubStateOK; + +#if FURI_DEBUG + FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); +#endif + } while(false); + + furi_string_free(temp_str); + return ret; +} diff --git a/applications/main/subghz_remote/helpers/subrem_presets.h b/applications/main/subghz_remote/helpers/subrem_presets.h index 60eedad576..fd4a2d7802 100644 --- a/applications/main/subghz_remote/helpers/subrem_presets.h +++ b/applications/main/subghz_remote/helpers/subrem_presets.h @@ -3,10 +3,12 @@ #include "subrem_types.h" #include #include +#include "../../subghz/helpers/subghz_txrx.h" typedef struct { + FuriString* name; uint32_t frequency; - uint8_t* data; + // size_t preset_index; // Need for custom preset } FreqPreset; // Sub File preset @@ -20,8 +22,17 @@ typedef struct { SubRemLoadSubState load_state; } SubRemSubFilePreset; +typedef struct { + SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; +} SubRemMapPreset; + SubRemSubFilePreset* subrem_sub_file_preset_alloc(); void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset); void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset); + +SubRemLoadSubState subrem_sub_preset_load( + SubRemSubFilePreset* sub_preset, + SubGhzTxRx* txrx, + FlipperFormat* fff_data_file); diff --git a/applications/main/subghz_remote/helpers/subrem_types.h b/applications/main/subghz_remote/helpers/subrem_types.h index 13b42897f6..def8078988 100644 --- a/applications/main/subghz_remote/helpers/subrem_types.h +++ b/applications/main/subghz_remote/helpers/subrem_types.h @@ -26,7 +26,7 @@ typedef enum { } SubRemViewID; typedef enum { - SubRemLoadSubStateNotSet, + SubRemLoadSubStateNotSet = 0, SubRemLoadSubStatePreloaded, SubRemLoadSubStateError, SubRemLoadSubStateErrorNoFile, diff --git a/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c b/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c index ea5c14a0a5..796699c831 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c @@ -4,7 +4,8 @@ void subrem_scene_openmapfile_on_enter(void* context) { SubGhzRemoteApp* app = context; SubRemLoadMapState load_state = subrem_load_from_file(app); - if(load_state == SubRemLoadMapStateError) { + if(load_state != SubRemLoadMapStateOK && load_state != SubRemLoadMapStateNotAllOK && + load_state != SubRemLoadMapStateBack) { #ifdef SUBREM_LIGHT dialog_message_show_storage_error(app->dialogs, "Can't load\nMap file"); #else diff --git a/applications/main/subghz_remote/scenes/subrem_scene_remote.c b/applications/main/subghz_remote/scenes/subrem_scene_remote.c index 1b8dbc4717..eaa1c41d94 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_remote.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_remote.c @@ -37,17 +37,16 @@ static uint8_t subrem_scene_remote_event_to_index(SubRemCustomEvent event_id) { static bool subrem_scene_remote_update_data_show(void* context) { SubGhzRemoteApp* app = context; - bool ret = false; - subrem_view_remote_add_data_to_show( - app->subrem_remote_view, - furi_string_get_cstr(app->map_preset->subs_preset[0]->label), - furi_string_get_cstr(app->map_preset->subs_preset[1]->label), - furi_string_get_cstr(app->map_preset->subs_preset[2]->label), - furi_string_get_cstr(app->map_preset->subs_preset[3]->label), - furi_string_get_cstr(app->map_preset->subs_preset[4]->label)); + const char* labels[SubRemSubKeyNameMaxCount]; - return ret; + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + labels[i] = furi_string_get_cstr(app->map_preset->subs_preset[i]->label); + } + + subrem_view_remote_add_data_to_show(app->subrem_remote_view, labels); + + return true; } void subrem_scene_remote_on_enter(void* context) { @@ -81,32 +80,37 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { event.event == SubRemCustomEventViewRemoteStartOK) { // Start sending sub subrem_tx_stop_sub(app, true); - app->chusen_sub = subrem_scene_remote_event_to_index(event.event); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateLoading); - if(subrem_tx_start_sub( - app, - app->map_preset->subs_preset[app->chusen_sub], - subrem_scene_remote_raw_callback_end_tx)) { - subrem_view_remote_set_presed_btn(app->subrem_remote_view, app->chusen_sub); + + uint8_t chusen_sub = subrem_scene_remote_event_to_index(event.event); + app->chusen_sub = chusen_sub; + + subrem_view_remote_set_state( + app->subrem_remote_view, SubRemViewRemoteStateLoading, chusen_sub); + + if(subrem_tx_start_sub(app, app->map_preset->subs_preset[chusen_sub])) { + if(app->map_preset->subs_preset[chusen_sub]->type == SubGhzProtocolTypeRAW) { + subghz_txrx_set_raw_file_encoder_worker_callback_end( + app->txrx, subrem_scene_remote_raw_callback_end_tx, app); + } subrem_view_remote_set_state( - app->subrem_remote_view, SubRemViewRemoteStateSending); + app->subrem_remote_view, SubRemViewRemoteStateSending, chusen_sub); notification_message(app->notifications, &sequence_blink_start_magenta); } else { - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + subrem_view_remote_set_state( + app->subrem_remote_view, SubRemViewRemoteStateIdle, 0); notification_message(app->notifications, &sequence_blink_stop); } return true; } else if(event.event == SubRemCustomEventViewRemoteForcedStop) { subrem_tx_stop_sub(app, true); - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle, 0); notification_message(app->notifications, &sequence_blink_stop); return true; } else if(event.event == SubRemCustomEventViewRemoteStop) { if(subrem_tx_stop_sub(app, false)) { - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + subrem_view_remote_set_state( + app->subrem_remote_view, SubRemViewRemoteStateIdle, 0); notification_message(app->notifications, &sequence_blink_stop); } @@ -123,8 +127,7 @@ void subrem_scene_remote_on_exit(void* context) { subrem_tx_stop_sub(app, true); - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle, 0); notification_message(app->notifications, &sequence_blink_stop); } diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index 4f9138e2aa..7383757d25 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -79,23 +79,9 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { app->map_preset->subs_preset[i] = subrem_sub_file_preset_alloc(); } - app->setting = subghz_setting_alloc(); - subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user")); + app->txrx = subghz_txrx_alloc(); - app->environment = subghz_environment_alloc(); - - subghz_environment_load_keystore(app->environment, EXT_PATH("subghz/assets/keeloq_mfcodes")); - subghz_environment_load_keystore( - app->environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user")); - subghz_environment_set_came_atomo_rainbow_table_file_name( - app->environment, EXT_PATH("subghz/assets/came_atomo")); - subghz_environment_set_alutech_at_4n_rainbow_table_file_name( - app->environment, EXT_PATH("subghz/assets/alutech_at_4n")); - subghz_environment_set_nice_flor_s_rainbow_table_file_name( - app->environment, EXT_PATH("subghz/assets/nice_flor_s")); - subghz_environment_set_protocol_registry(app->environment, (void*)&subghz_protocol_registry); - - app->receiver = subghz_receiver_alloc_init(app->environment); + subghz_txrx_set_need_save_callback(app->txrx, subrem_save_active_sub, app); app->tx_running = false; @@ -132,9 +118,7 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { scene_manager_free(app->scene_manager); view_dispatcher_free(app->view_dispatcher); - subghz_receiver_free(app->receiver); - subghz_environment_free(app->environment); - subghz_setting_free(app->setting); + subghz_txrx_free(app->txrx); for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { subrem_sub_file_preset_free(app->map_preset->subs_preset[i]); diff --git a/applications/main/subghz_remote/subghz_remote_app_i.c b/applications/main/subghz_remote/subghz_remote_app_i.c index 9c35a0e036..fb34b59f70 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.c +++ b/applications/main/subghz_remote/subghz_remote_app_i.c @@ -4,6 +4,8 @@ #include +#include "../subghz/helpers/subghz_txrx_i.h" + // #include // #include @@ -11,6 +13,12 @@ #define TAG "SubGhzRemote" +// XXX Using TxRx +// [x] use TxRx preset subrem_sub_preset_load & subrem_tx_start_sub +// [x] subrem_sub_preset_load & drop subrem_set_preset_data +// [x] subrem_tx_start_sub +// [x] subrem_tx_stop_sub + static const char* map_file_labels[SubRemSubKeyNameMaxCount][2] = { [SubRemSubKeyNameUp] = {"UP", "ULABEL"}, [SubRemSubKeyNameDown] = {"DOWN", "DLABEL"}, @@ -19,43 +27,69 @@ static const char* map_file_labels[SubRemSubKeyNameMaxCount][2] = { [SubRemSubKeyNameOk] = {"OK", "OKLABEL"}, }; -static bool - subrem_set_preset_data(SubGhzSetting* setting, FreqPreset* freq_preset, const char* preset) { - const char* preset_name = ""; - if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) { - preset_name = "AM270"; - } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) { - preset_name = "AM650"; - } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) { - preset_name = "FM238"; - } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) { - preset_name = "FM476"; - } else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) { - // preset_name = "CUSTOM"; - return false; - } else { - FURI_LOG_E(TAG, "Unknown preset"); - return false; +static void subrem_map_preset_reset(SubRemMapPreset* map_preset) { + furi_assert(map_preset); + + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + subrem_sub_file_preset_reset(map_preset->subs_preset[i]); } - size_t preset_index = subghz_setting_get_inx_preset_by_name(setting, preset_name); - freq_preset->data = subghz_setting_get_preset_data(setting, preset_index); - return true; } -void subrem_map_preset_reset(SubRemMapPreset* map_preset) { +static SubRemLoadMapState subrem_map_preset_check( + SubRemMapPreset* map_preset, + SubGhzTxRx* txrx, + FlipperFormat* fff_data_file) { furi_assert(map_preset); + furi_assert(txrx); + + bool all_loaded = true; + SubRemLoadMapState ret = SubRemLoadMapStateErrorBrokenFile; + + SubRemLoadSubState sub_preset_loaded; + SubRemSubFilePreset* sub_preset; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - subrem_sub_file_preset_reset(map_preset->subs_preset[i]); + sub_preset = map_preset->subs_preset[i]; + + sub_preset_loaded = SubRemLoadSubStateErrorNoFile; + + if(furi_string_empty(sub_preset->file_path)) { + // FURI_LOG_I(TAG, "Empty file path"); + } else if(!flipper_format_file_open_existing( + fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { + FURI_LOG_W(TAG, "Error open file %s", furi_string_get_cstr(sub_preset->file_path)); + } else { + sub_preset_loaded = subrem_sub_preset_load(sub_preset, txrx, fff_data_file); + } + + // TODO: + // Load file state logic + // Label depending on the state + // Move to remote scene + + if(sub_preset_loaded != SubRemLoadSubStateOK) { + furi_string_set_str(sub_preset->label, "N/A"); + all_loaded = false; + } else { + ret = SubRemLoadMapStateNotAllOK; + } + + if(ret != SubRemLoadMapStateErrorBrokenFile && all_loaded) { + ret = SubRemLoadMapStateOK; + } + + flipper_format_file_close(fff_data_file); } + + return ret; } -static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { - furi_assert(app); +static bool subrem_map_preset_load(SubRemMapPreset* map_preset, FlipperFormat* fff_data_file) { + furi_assert(map_preset); bool ret = false; SubRemSubFilePreset* sub_preset; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - sub_preset = app->map_preset->subs_preset[i]; + sub_preset = map_preset->subs_preset[i]; if(!flipper_format_read_string( fff_data_file, map_file_labels[i][0], sub_preset->file_path)) { #if FURI_DEBUG @@ -69,8 +103,13 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data #if FURI_DEBUG FURI_LOG_W(TAG, "No Label for %s", map_file_labels[i][0]); #endif + // TODO move to remote scene path_extract_filename(sub_preset->file_path, sub_preset->label, true); + ret = true; } else { + ret = true; + } + if(ret) { // Preload seccesful FURI_LOG_I( TAG, @@ -78,154 +117,11 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data map_file_labels[i][0], furi_string_get_cstr(sub_preset->label), furi_string_get_cstr(sub_preset->file_path)); - ret = true; sub_preset->load_state = SubRemLoadSubStatePreloaded; } - flipper_format_rewind(fff_data_file); - } - return ret; -} - -static SubRemLoadMapState - subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { - furi_assert(app); - FuriString* temp_str = furi_string_alloc(); - uint32_t temp_data32; - bool all_loaded = true; - SubRemLoadMapState ret = SubRemLoadMapStateErrorBrokenFile; - SubRemLoadSubState sub_preset_loaded; - SubRemSubFilePreset* sub_preset; - uint32_t repeat = 200; - for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - sub_preset = app->map_preset->subs_preset[i]; - if(furi_string_empty(sub_preset->file_path)) { - // FURI_LOG_I(TAG, "Empty file path"); - continue; - } - - sub_preset_loaded = SubRemLoadSubStateErrorNoFile; - repeat = 200; - do { - if(!flipper_format_file_open_existing( - fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { - FURI_LOG_W(TAG, "Error open file %s", furi_string_get_cstr(sub_preset->file_path)); - break; - } - - if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) { - FURI_LOG_E(TAG, "Missing or incorrect header"); - break; - } - - if(((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) || - (!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) && - temp_data32 == SUBGHZ_KEY_FILE_VERSION) { - } else { - FURI_LOG_E(TAG, "Type or version mismatch"); - break; - } - - //Load frequency - sub_preset_loaded = SubRemLoadSubStateErrorFreq; - if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { - FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); - sub_preset->freq_preset.frequency = - subghz_setting_get_default_frequency(app->setting); - } else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { - FURI_LOG_E(TAG, "This frequency can only be used for RX"); - break; - } else { - sub_preset->freq_preset.frequency = temp_data32; - } - - //Load preset - sub_preset_loaded = SubRemLoadSubStateErrorMod; - if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { - FURI_LOG_E(TAG, "Missing Preset"); - break; - } - - if(!subrem_set_preset_data( - app->setting, &sub_preset->freq_preset, furi_string_get_cstr(temp_str))) { - FURI_LOG_E(TAG, "Cannot load preset."); - break; - } - - //Load protocol - sub_preset_loaded = SubRemLoadSubStateErrorProtocol; - if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { - FURI_LOG_E(TAG, "Missing Protocol"); - break; - } - - FlipperFormat* fff_data = sub_preset->fff_data; - if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) { - //if RAW - subghz_protocol_raw_gen_fff_data( - fff_data, furi_string_get_cstr(sub_preset->file_path)); - } else { - stream_copy_full( - flipper_format_get_raw_stream(fff_data_file), - flipper_format_get_raw_stream(fff_data)); - } - - const SubGhzProtocolRegistry* protocol_registry_items = - subghz_environment_get_protocol_registry(app->environment); - - const SubGhzProtocol* protocol = subghz_protocol_registry_get_by_name( - protocol_registry_items, furi_string_get_cstr(temp_str)); - - if(!protocol) { - FURI_LOG_E(TAG, "Protocol not found"); - break; - } else if(protocol->flag & SubGhzProtocolFlag_Send) { - if((protocol->type == SubGhzProtocolTypeStatic) || - (protocol->type == SubGhzProtocolTypeDynamic) || - // (protocol->type == SubGhzProtocolTypeBinRAW) || // TODO: BINRAW - (protocol->type == SubGhzProtocolTypeRAW)) { - sub_preset->type = protocol->type; - } else { - FURI_LOG_E(TAG, "Unsuported Protocol"); - break; - } - - furi_string_set(sub_preset->protocaol_name, temp_str); - } else { - FURI_LOG_E(TAG, "Protocol does not support transmission"); - } - - if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &repeat, 1)) { - FURI_LOG_E(TAG, "Unable Repeat"); - break; - } - - sub_preset_loaded = SubRemLoadSubStateOK; - ret = SubRemLoadMapStateNotAllOK; - -#if FURI_DEBUG - FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); -#endif - } while(false); - - // TODO: - // Load file state logic - // Label depending on the state - // Move to remote scene - - if(sub_preset_loaded != SubRemLoadSubStateOK) { - furi_string_set_str(sub_preset->label, "N/A"); - all_loaded = false; - } - - if(ret != SubRemLoadMapStateErrorBrokenFile && all_loaded) { - ret = SubRemLoadMapStateOK; - } - - flipper_format_file_close(fff_data_file); + flipper_format_rewind(fff_data_file); } - furi_string_free(temp_str); - return ret; } @@ -247,13 +143,13 @@ SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_p FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); ret = SubRemLoadMapStateErrorOpenError; } else { - if(!subrem_map_preset_load(app, fff_data_file)) { + if(!subrem_map_preset_load(app->map_preset, fff_data_file)) { FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); // ret = // error for popup } else if(!flipper_format_file_close(fff_data_file)) { ret = SubRemLoadMapStateErrorOpenError; } else { - ret = subrem_map_preset_check(app, fff_data_file); + ret = subrem_map_preset_check(app->map_preset, app->txrx, fff_data_file); } } @@ -272,9 +168,9 @@ SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_p return ret; } -bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { +bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* sub_file_name) { furi_assert(flipper_format); - furi_assert(dev_file_name); + furi_assert(sub_file_name); Storage* storage = furi_record_open(RECORD_STORAGE); Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); @@ -283,19 +179,19 @@ bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev uint32_t repeat = 200; FuriString* file_dir = furi_string_alloc(); - path_extract_dirname(dev_file_name, file_dir); + path_extract_dirname(sub_file_name, file_dir); do { // removing additional fields flipper_format_delete_key(flipper_format, "Repeat"); // flipper_format_delete_key(flipper_format, "Manufacture"); - if(!storage_simply_remove(storage, dev_file_name)) { + if(!storage_simply_remove(storage, sub_file_name)) { break; } //ToDo check Write stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); - stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); + stream_save_to_file(flipper_format_stream, storage, sub_file_name, FSOM_CREATE_ALWAYS); if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { FURI_LOG_E(TAG, "Unable Repeat"); @@ -310,10 +206,16 @@ bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev return saved; } -bool subrem_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback) { +void subrem_save_active_sub(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + + SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub]; + subrem_save_protocol_to_file( + sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); +} + +bool subrem_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { furi_assert(app); furi_assert(sub_preset); bool ret = false; @@ -321,88 +223,44 @@ bool subrem_tx_start_sub( subrem_tx_stop_sub(app, true); if(sub_preset->type == SubGhzProtocolTypeUnknown) { - return false; - } - - FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); - - subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); - keeloq_reset_original_btn(); - subghz_custom_btns_reset(); - - do { - flipper_format_rewind(sub_preset->fff_data); // - - app->transmitter = subghz_transmitter_alloc_init( - app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); + ret = false; + } else { + FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); - if(app->transmitter) { - if(subghz_transmitter_deserialize(app->transmitter, sub_preset->fff_data) != - SubGhzProtocolStatusOk) { - FURI_LOG_E(TAG, "Deserialize error!"); - break; - } - furi_hal_subghz_reset(); - furi_hal_subghz_idle(); - furi_hal_subghz_load_custom_preset(sub_preset->freq_preset.data); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); - - furi_hal_subghz_idle(); - - furi_hal_subghz_set_frequency_and_path(sub_preset->freq_preset.frequency); - furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - - if(!furi_hal_subghz_tx()) { - FURI_LOG_E(TAG, "Sending not allowed"); - break; - } + subghz_txrx_load_decoder_by_name_protocol( + app->txrx, furi_string_get_cstr(sub_preset->protocaol_name)); - if(sub_preset->type == SubGhzProtocolTypeRAW) { - subghz_protocol_raw_file_encoder_worker_set_callback_end( - (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( - app->transmitter), - callback, - app); - } + subghz_txrx_set_preset( + app->txrx, + furi_string_get_cstr(sub_preset->freq_preset.name), + sub_preset->freq_preset.frequency, + NULL, + 0); - furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); + subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); + keeloq_reset_original_btn(); + subghz_custom_btns_reset(); + if(subghz_txrx_tx_start(app->txrx, sub_preset->fff_data) == SubGhzTxRxStartTxStateOk) { ret = true; } - } while(false); + } app->tx_running = ret; return ret; } -static void subghz_tx_stop(SubGhzRemoteApp* app) { - furi_assert(app); - - //Stop TX - furi_hal_subghz_stop_async_tx(); - - subghz_transmitter_stop(app->transmitter); - subghz_transmitter_free(app->transmitter); - furi_hal_subghz_idle(); -} - bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { furi_assert(app); SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub]; if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) { - // SubRemSubKeyTypeRawKey)) { + // XXX drop app->tx_running if(app->tx_running) { - subghz_tx_stop(app); + subghz_txrx_stop(app->txrx); if(sub_preset->type == SubGhzProtocolTypeDynamic) { - subrem_save_protocol_to_file( - sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); - keeloq_reset_mfname(); keeloq_reset_kl_type(); keeloq_reset_original_btn(); diff --git a/applications/main/subghz_remote/subghz_remote_app_i.h b/applications/main/subghz_remote/subghz_remote_app_i.h index 5d34968cdc..50e2bae9f8 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.h +++ b/applications/main/subghz_remote/subghz_remote_app_i.h @@ -3,6 +3,8 @@ #include "helpers/subrem_types.h" #include "helpers/subrem_presets.h" +#include "../subghz/helpers/subghz_txrx.h" + #include #include "views/remote.h" @@ -31,9 +33,6 @@ #define SUBREM_APP_FOLDER EXT_PATH("subghz_remote") #define SUBREM_MAX_LEN_NAME 64 -typedef struct { - SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; -} SubRemMapPreset; typedef struct { Gui* gui; ViewDispatcher* view_dispatcher; @@ -49,10 +48,7 @@ typedef struct { SubRemMapPreset* map_preset; - SubGhzSetting* setting; - SubGhzEnvironment* environment; - SubGhzReceiver* receiver; - SubGhzTransmitter* transmitter; + SubGhzTxRx* txrx; bool tx_running; @@ -61,9 +57,8 @@ typedef struct { SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app); -bool subrem_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback); +bool subrem_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); + +bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced); -bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced); \ No newline at end of file +void subrem_save_active_sub(void* context); \ No newline at end of file diff --git a/applications/main/subghz_remote/views/remote.c b/applications/main/subghz_remote/views/remote.c index 1f867cd0b6..e062f11b1d 100644 --- a/applications/main/subghz_remote/views/remote.c +++ b/applications/main/subghz_remote/views/remote.c @@ -41,24 +41,18 @@ void subrem_view_remote_set_callback( subrem_view_remote->context = context; } -void subrem_view_remote_add_data_to_show( - SubRemViewRemote* subrem_view_remote, - const char* up_label, - const char* down_label, - const char* left_label, - const char* right_label, - const char* ok_label) { +void subrem_view_remote_add_data_to_show(SubRemViewRemote* subrem_view_remote, const char** labels) { furi_assert(subrem_view_remote); with_view_model( subrem_view_remote->view, SubRemViewRemoteModel * model, { - strncpy(model->up_label, up_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->down_label, down_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->left_label, left_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->right_label, right_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->ok_label, ok_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->up_label, labels[0], SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->down_label, labels[1], SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->left_label, labels[2], SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->right_label, labels[3], SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->ok_label, labels[4], SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); // furi_string_set(model->up_label, up_label); // furi_string_set(model->down_label, down_label); @@ -69,23 +63,21 @@ void subrem_view_remote_add_data_to_show( true); } -void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn) { +void subrem_view_remote_set_state( + SubRemViewRemote* subrem_view_remote, + SubRemViewRemoteState state, + uint8_t presed_btn) { furi_assert(subrem_view_remote); with_view_model( subrem_view_remote->view, SubRemViewRemoteModel * model, - { model->pressed_btn = presed_btn; }, + { + model->state = state; + model->pressed_btn = presed_btn; + }, true); } -void subrem_view_remote_set_state( - SubRemViewRemote* subrem_view_remote, - SubRemViewRemoteState state) { - furi_assert(subrem_view_remote); - with_view_model( - subrem_view_remote->view, SubRemViewRemoteModel * model, { model->state = state; }, true); -} - void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); diff --git a/applications/main/subghz_remote/views/remote.h b/applications/main/subghz_remote/views/remote.h index 76121cf8a0..ea274fca4f 100644 --- a/applications/main/subghz_remote/views/remote.h +++ b/applications/main/subghz_remote/views/remote.h @@ -24,15 +24,9 @@ void subrem_view_remote_free(SubRemViewRemote* subrem_view_remote); View* subrem_view_remote_get_view(SubRemViewRemote* subrem_view_remote); -void subrem_view_remote_add_data_to_show( - SubRemViewRemote* subrem_view_remote, - const char* up_label, - const char* down_label, - const char* left_label, - const char* right_label, - const char* ok_label); +void subrem_view_remote_add_data_to_show(SubRemViewRemote* subrem_view_remote, const char** labels); -void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn); void subrem_view_remote_set_state( SubRemViewRemote* subrem_view_remote, - SubRemViewRemoteState state); \ No newline at end of file + SubRemViewRemoteState state, + uint8_t presed_btn); \ No newline at end of file From e71a66535d3d151af82d02029a8f7bf9396eb2d7 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sun, 21 May 2023 10:29:58 +0300 Subject: [PATCH 38/92] move part of preset --- .../subghz_remote/helpers/subrem_presets.c | 40 ++ .../subghz_remote/helpers/subrem_presets.h | 27 ++ .../scenes/subrem_scene_remote.c | 12 +- .../main/subghz_remote/subghz_remote_app.c | 6 +- .../main/subghz_remote/subghz_remote_app_i.c | 345 ++++++++---------- .../main/subghz_remote/subghz_remote_app_i.h | 28 +- 6 files changed, 237 insertions(+), 221 deletions(-) create mode 100644 applications/main/subghz_remote/helpers/subrem_presets.c create mode 100644 applications/main/subghz_remote/helpers/subrem_presets.h diff --git a/applications/main/subghz_remote/helpers/subrem_presets.c b/applications/main/subghz_remote/helpers/subrem_presets.c new file mode 100644 index 0000000000..03e497198b --- /dev/null +++ b/applications/main/subghz_remote/helpers/subrem_presets.c @@ -0,0 +1,40 @@ +#include "subrem_presets.h" + +SubRemSubFilePreset* subrem_sub_file_preset_alloc() { + SubRemSubFilePreset* sub_preset = malloc(sizeof(SubRemSubFilePreset)); + + sub_preset->fff_data = flipper_format_string_alloc(); + sub_preset->file_path = furi_string_alloc(); + sub_preset->protocaol_name = furi_string_alloc(); + sub_preset->label = furi_string_alloc_set_str("N/A"); + + sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; + + return sub_preset; +} + +void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { + furi_assert(sub_preset); + + furi_string_free(sub_preset->label); + furi_string_free(sub_preset->protocaol_name); + furi_string_free(sub_preset->file_path); + flipper_format_free(sub_preset->fff_data); + + free(sub_preset); +} + +void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { + furi_assert(sub_preset); + + furi_string_set_str(sub_preset->label, "N/A"); + furi_string_reset(sub_preset->protocaol_name); + furi_string_reset(sub_preset->file_path); + + Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); + stream_clean(fff_data_stream); + + sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; +} diff --git a/applications/main/subghz_remote/helpers/subrem_presets.h b/applications/main/subghz_remote/helpers/subrem_presets.h new file mode 100644 index 0000000000..60eedad576 --- /dev/null +++ b/applications/main/subghz_remote/helpers/subrem_presets.h @@ -0,0 +1,27 @@ +#pragma once + +#include "subrem_types.h" +#include +#include + +typedef struct { + uint32_t frequency; + uint8_t* data; +} FreqPreset; + +// Sub File preset +typedef struct { + FlipperFormat* fff_data; + FreqPreset freq_preset; + FuriString* file_path; + FuriString* protocaol_name; + FuriString* label; + SubGhzProtocolType type; + SubRemLoadSubState load_state; +} SubRemSubFilePreset; + +SubRemSubFilePreset* subrem_sub_file_preset_alloc(); + +void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset); + +void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset); diff --git a/applications/main/subghz_remote/scenes/subrem_scene_remote.c b/applications/main/subghz_remote/scenes/subrem_scene_remote.c index c245832336..1b8dbc4717 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_remote.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_remote.c @@ -41,11 +41,11 @@ static bool subrem_scene_remote_update_data_show(void* context) { subrem_view_remote_add_data_to_show( app->subrem_remote_view, - furi_string_get_cstr(app->subs_preset[0]->label), - furi_string_get_cstr(app->subs_preset[1]->label), - furi_string_get_cstr(app->subs_preset[2]->label), - furi_string_get_cstr(app->subs_preset[3]->label), - furi_string_get_cstr(app->subs_preset[4]->label)); + furi_string_get_cstr(app->map_preset->subs_preset[0]->label), + furi_string_get_cstr(app->map_preset->subs_preset[1]->label), + furi_string_get_cstr(app->map_preset->subs_preset[2]->label), + furi_string_get_cstr(app->map_preset->subs_preset[3]->label), + furi_string_get_cstr(app->map_preset->subs_preset[4]->label)); return ret; } @@ -85,7 +85,7 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateLoading); if(subrem_tx_start_sub( app, - app->subs_preset[app->chusen_sub], + app->map_preset->subs_preset[app->chusen_sub], subrem_scene_remote_raw_callback_end_tx)) { subrem_view_remote_set_presed_btn(app->subrem_remote_view, app->chusen_sub); subrem_view_remote_set_state( diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index b957fb8bcb..4f9138e2aa 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -74,8 +74,9 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { SubRemViewIDRemote, subrem_view_remote_get_view(app->subrem_remote_view)); + app->map_preset = malloc(sizeof(SubRemMapPreset)); for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - app->subs_preset[i] = subrem_sub_file_preset_alloc(); + app->map_preset->subs_preset[i] = subrem_sub_file_preset_alloc(); } app->setting = subghz_setting_alloc(); @@ -136,8 +137,9 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { subghz_setting_free(app->setting); for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - subrem_sub_file_preset_free(app->subs_preset[i]); + subrem_sub_file_preset_free(app->map_preset->subs_preset[i]); } + free(app->map_preset); // Notifications furi_record_close(RECORD_NOTIFICATION); diff --git a/applications/main/subghz_remote/subghz_remote_app_i.c b/applications/main/subghz_remote/subghz_remote_app_i.c index 349fb87cdb..9c35a0e036 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.c +++ b/applications/main/subghz_remote/subghz_remote_app_i.c @@ -42,50 +42,11 @@ static bool return true; } -SubRemSubFilePreset* subrem_sub_file_preset_alloc() { - SubRemSubFilePreset* sub_preset = malloc(sizeof(SubRemSubFilePreset)); - - sub_preset->fff_data = flipper_format_string_alloc(); - sub_preset->file_path = furi_string_alloc(); - sub_preset->protocaol_name = furi_string_alloc(); - sub_preset->label = furi_string_alloc_set_str("N/A"); - - sub_preset->type = SubGhzProtocolTypeUnknown; - sub_preset->load_state = SubRemLoadSubStateNotSet; - - return sub_preset; -} - -void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { - furi_assert(sub_preset); - - furi_string_free(sub_preset->label); - furi_string_free(sub_preset->protocaol_name); - furi_string_free(sub_preset->file_path); - flipper_format_free(sub_preset->fff_data); - - free(sub_preset); -} - -static void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { - furi_assert(sub_preset); - - furi_string_set_str(sub_preset->label, "N/A"); - furi_string_reset(sub_preset->protocaol_name); - furi_string_reset(sub_preset->file_path); - - Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); - stream_clean(fff_data_stream); - - sub_preset->type = SubGhzProtocolTypeUnknown; - sub_preset->load_state = SubRemLoadSubStateNotSet; -} - -void subrem_map_preset_reset(SubGhzRemoteApp* app) { - furi_assert(app); +void subrem_map_preset_reset(SubRemMapPreset* map_preset) { + furi_assert(map_preset); for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - subrem_sub_file_preset_reset(app->subs_preset[i]); + subrem_sub_file_preset_reset(map_preset->subs_preset[i]); } } @@ -94,7 +55,7 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data bool ret = false; SubRemSubFilePreset* sub_preset; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - sub_preset = app->subs_preset[i]; + sub_preset = app->map_preset->subs_preset[i]; if(!flipper_format_read_string( fff_data_file, map_file_labels[i][0], sub_preset->file_path)) { #if FURI_DEBUG @@ -125,153 +86,6 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data return ret; } -bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { - furi_assert(flipper_format); - furi_assert(dev_file_name); - - Storage* storage = furi_record_open(RECORD_STORAGE); - Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); - - bool saved = false; - uint32_t repeat = 200; - FuriString* file_dir = furi_string_alloc(); - - path_extract_dirname(dev_file_name, file_dir); - do { - // removing additional fields - flipper_format_delete_key(flipper_format, "Repeat"); - // flipper_format_delete_key(flipper_format, "Manufacture"); - - if(!storage_simply_remove(storage, dev_file_name)) { - break; - } - - //ToDo check Write - stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); - stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); - - if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { - FURI_LOG_E(TAG, "Unable Repeat"); - break; - } - - saved = true; - } while(0); - - furi_string_free(file_dir); - furi_record_close(RECORD_STORAGE); - return saved; -} - -bool subrem_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback) { - furi_assert(app); - furi_assert(sub_preset); - bool ret = false; - - subrem_tx_stop_sub(app, true); - - if(sub_preset->type == SubGhzProtocolTypeUnknown) { - return false; - } - - FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); - - subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); - keeloq_reset_original_btn(); - subghz_custom_btns_reset(); - - do { - flipper_format_rewind(sub_preset->fff_data); // - - app->transmitter = subghz_transmitter_alloc_init( - app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); - - if(app->transmitter) { - if(subghz_transmitter_deserialize(app->transmitter, sub_preset->fff_data) != - SubGhzProtocolStatusOk) { - FURI_LOG_E(TAG, "Deserialize error!"); - break; - } - furi_hal_subghz_reset(); - furi_hal_subghz_idle(); - furi_hal_subghz_load_custom_preset(sub_preset->freq_preset.data); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); - - furi_hal_subghz_idle(); - - furi_hal_subghz_set_frequency_and_path(sub_preset->freq_preset.frequency); - furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - - if(!furi_hal_subghz_tx()) { - FURI_LOG_E(TAG, "Sending not allowed"); - break; - } - - if(sub_preset->type == SubGhzProtocolTypeRAW) { - subghz_protocol_raw_file_encoder_worker_set_callback_end( - (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( - app->transmitter), - callback, - app); - } - - furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); - - ret = true; - } - } while(false); - - app->tx_running = ret; - - return ret; -} - -static void subghz_tx_stop(SubGhzRemoteApp* app) { - furi_assert(app); - - //Stop TX - furi_hal_subghz_stop_async_tx(); - - subghz_transmitter_stop(app->transmitter); - subghz_transmitter_free(app->transmitter); - furi_hal_subghz_idle(); -} - -bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { - furi_assert(app); - SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; - - if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) { - // SubRemSubKeyTypeRawKey)) { - if(app->tx_running) { - subghz_tx_stop(app); - - if(sub_preset->type == SubGhzProtocolTypeDynamic) { - subrem_save_protocol_to_file( - sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); - - keeloq_reset_mfname(); - keeloq_reset_kl_type(); - keeloq_reset_original_btn(); - subghz_custom_btns_reset(); - star_line_reset_mfname(); - star_line_reset_kl_type(); - } - - app->tx_running = false; - return true; - } - } - - return false; -} - static SubRemLoadMapState subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); @@ -283,7 +97,7 @@ static SubRemLoadMapState SubRemSubFilePreset* sub_preset; uint32_t repeat = 200; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - sub_preset = app->subs_preset[i]; + sub_preset = app->map_preset->subs_preset[i]; if(furi_string_empty(sub_preset->file_path)) { // FURI_LOG_I(TAG, "Empty file path"); continue; @@ -427,7 +241,7 @@ SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_p #if FURI_DEBUG FURI_LOG_I(TAG, "Open Map File.."); #endif - subrem_map_preset_reset(app); + subrem_map_preset_reset(app->map_preset); if(!flipper_format_file_open_existing(fff_data_file, file_path)) { FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); @@ -458,6 +272,153 @@ SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_p return ret; } +bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { + furi_assert(flipper_format); + furi_assert(dev_file_name); + + Storage* storage = furi_record_open(RECORD_STORAGE); + Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); + + bool saved = false; + uint32_t repeat = 200; + FuriString* file_dir = furi_string_alloc(); + + path_extract_dirname(dev_file_name, file_dir); + do { + // removing additional fields + flipper_format_delete_key(flipper_format, "Repeat"); + // flipper_format_delete_key(flipper_format, "Manufacture"); + + if(!storage_simply_remove(storage, dev_file_name)) { + break; + } + + //ToDo check Write + stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); + stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); + + if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + + saved = true; + } while(0); + + furi_string_free(file_dir); + furi_record_close(RECORD_STORAGE); + return saved; +} + +bool subrem_tx_start_sub( + SubGhzRemoteApp* app, + SubRemSubFilePreset* sub_preset, + SubGhzProtocolEncoderRAWCallbackEnd callback) { + furi_assert(app); + furi_assert(sub_preset); + bool ret = false; + + subrem_tx_stop_sub(app, true); + + if(sub_preset->type == SubGhzProtocolTypeUnknown) { + return false; + } + + FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); + + subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); + keeloq_reset_original_btn(); + subghz_custom_btns_reset(); + + do { + flipper_format_rewind(sub_preset->fff_data); // + + app->transmitter = subghz_transmitter_alloc_init( + app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); + + if(app->transmitter) { + if(subghz_transmitter_deserialize(app->transmitter, sub_preset->fff_data) != + SubGhzProtocolStatusOk) { + FURI_LOG_E(TAG, "Deserialize error!"); + break; + } + furi_hal_subghz_reset(); + furi_hal_subghz_idle(); + furi_hal_subghz_load_custom_preset(sub_preset->freq_preset.data); + furi_hal_gpio_init( + furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); + + furi_hal_subghz_idle(); + + furi_hal_subghz_set_frequency_and_path(sub_preset->freq_preset.frequency); + furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); + furi_hal_gpio_init( + furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); + + if(!furi_hal_subghz_tx()) { + FURI_LOG_E(TAG, "Sending not allowed"); + break; + } + + if(sub_preset->type == SubGhzProtocolTypeRAW) { + subghz_protocol_raw_file_encoder_worker_set_callback_end( + (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( + app->transmitter), + callback, + app); + } + + furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); + + ret = true; + } + } while(false); + + app->tx_running = ret; + + return ret; +} + +static void subghz_tx_stop(SubGhzRemoteApp* app) { + furi_assert(app); + + //Stop TX + furi_hal_subghz_stop_async_tx(); + + subghz_transmitter_stop(app->transmitter); + subghz_transmitter_free(app->transmitter); + furi_hal_subghz_idle(); +} + +bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { + furi_assert(app); + SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub]; + + if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) { + // SubRemSubKeyTypeRawKey)) { + if(app->tx_running) { + subghz_tx_stop(app); + + if(sub_preset->type == SubGhzProtocolTypeDynamic) { + subrem_save_protocol_to_file( + sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); + + keeloq_reset_mfname(); + keeloq_reset_kl_type(); + keeloq_reset_original_btn(); + subghz_custom_btns_reset(); + star_line_reset_mfname(); + star_line_reset_kl_type(); + } + + app->tx_running = false; + return true; + } + } + + return false; +} + SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) { furi_assert(app); diff --git a/applications/main/subghz_remote/subghz_remote_app_i.h b/applications/main/subghz_remote/subghz_remote_app_i.h index 40d70411ab..5d34968cdc 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.h +++ b/applications/main/subghz_remote/subghz_remote_app_i.h @@ -1,6 +1,8 @@ #pragma once #include "helpers/subrem_types.h" +#include "helpers/subrem_presets.h" + #include #include "views/remote.h" @@ -30,25 +32,8 @@ #define SUBREM_MAX_LEN_NAME 64 typedef struct { - uint32_t frequency; - uint8_t* data; -} FreqPreset; - -// Sub File preset -typedef struct { - FlipperFormat* fff_data; - FreqPreset freq_preset; - FuriString* file_path; - FuriString* protocaol_name; - FuriString* label; - SubGhzProtocolType type; - SubRemLoadSubState load_state; -} SubRemSubFilePreset; - -SubRemSubFilePreset* subrem_sub_file_preset_alloc(); - -void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset); - + SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; +} SubRemMapPreset; typedef struct { Gui* gui; ViewDispatcher* view_dispatcher; @@ -56,12 +41,13 @@ typedef struct { NotificationApp* notifications; DialogsApp* dialogs; Submenu* submenu; + FuriString* file_path; - char file_name_tmp[SUBREM_MAX_LEN_NAME]; + // char file_name_tmp[SUBREM_MAX_LEN_NAME]; SubRemViewRemote* subrem_remote_view; - SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; + SubRemMapPreset* map_preset; SubGhzSetting* setting; SubGhzEnvironment* environment; From 58b21f2a49aa5608c297be0ab0c1dd4bfdd858ac Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sun, 21 May 2023 23:34:42 +0300 Subject: [PATCH 39/92] Using TxRx from subghz --- .../subghz_remote/helpers/subrem_presets.c | 139 +++++++ .../subghz_remote/helpers/subrem_presets.h | 13 +- .../main/subghz_remote/helpers/subrem_types.h | 2 +- .../scenes/subrem_scene_openmapfile.c | 3 +- .../scenes/subrem_scene_remote.c | 51 +-- .../main/subghz_remote/subghz_remote_app.c | 22 +- .../main/subghz_remote/subghz_remote_app_i.c | 342 +++++------------- .../main/subghz_remote/subghz_remote_app_i.h | 19 +- .../main/subghz_remote/views/remote.c | 36 +- .../main/subghz_remote/views/remote.h | 12 +- 10 files changed, 308 insertions(+), 331 deletions(-) diff --git a/applications/main/subghz_remote/helpers/subrem_presets.c b/applications/main/subghz_remote/helpers/subrem_presets.c index 03e497198b..9601aae6ce 100644 --- a/applications/main/subghz_remote/helpers/subrem_presets.c +++ b/applications/main/subghz_remote/helpers/subrem_presets.c @@ -1,5 +1,7 @@ #include "subrem_presets.h" +#define TAG "SubRemPresets" + SubRemSubFilePreset* subrem_sub_file_preset_alloc() { SubRemSubFilePreset* sub_preset = malloc(sizeof(SubRemSubFilePreset)); @@ -8,6 +10,8 @@ SubRemSubFilePreset* subrem_sub_file_preset_alloc() { sub_preset->protocaol_name = furi_string_alloc(); sub_preset->label = furi_string_alloc_set_str("N/A"); + sub_preset->freq_preset.name = furi_string_alloc(); + sub_preset->type = SubGhzProtocolTypeUnknown; sub_preset->load_state = SubRemLoadSubStateNotSet; @@ -22,6 +26,8 @@ void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { furi_string_free(sub_preset->file_path); flipper_format_free(sub_preset->fff_data); + furi_string_free(sub_preset->freq_preset.name); + free(sub_preset); } @@ -38,3 +44,136 @@ void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { sub_preset->type = SubGhzProtocolTypeUnknown; sub_preset->load_state = SubRemLoadSubStateNotSet; } + +SubRemLoadSubState subrem_sub_preset_load( + SubRemSubFilePreset* sub_preset, + SubGhzTxRx* txrx, + FlipperFormat* fff_data_file) { + furi_assert(sub_preset); + furi_assert(txrx); + furi_assert(fff_data_file); + + Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); + + SubRemLoadSubState ret; + FuriString* temp_str = furi_string_alloc(); + uint32_t temp_data32; + uint32_t repeat = 200; + + ret = SubRemLoadSubStateError; + + do { + stream_clean(fff_data_stream); + if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) { + FURI_LOG_E(TAG, "Missing or incorrect header"); + break; + } + + if(((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) || + (!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) && + temp_data32 == SUBGHZ_KEY_FILE_VERSION) { + } else { + FURI_LOG_E(TAG, "Type or version mismatch"); + break; + } + + SubGhzSetting* setting = subghz_txrx_get_setting(txrx); // txrx->setting; + + //Load frequency or using default from settings + ret = SubRemLoadSubStateErrorFreq; + if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { + FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); + sub_preset->freq_preset.frequency = subghz_setting_get_default_frequency(setting); + } else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { + FURI_LOG_E(TAG, "This frequency can only be used for RX"); + break; + } + sub_preset->freq_preset.frequency = temp_data32; + + //Load preset + ret = SubRemLoadSubStateErrorMod; + if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { + FURI_LOG_E(TAG, "Missing Preset"); + break; + } + + furi_string_set_str( + temp_str, subghz_txrx_get_preset_name(txrx, furi_string_get_cstr(temp_str))); + if(!strcmp(furi_string_get_cstr(temp_str), "")) { + break; + } + + if(!strcmp(furi_string_get_cstr(temp_str), "CUSTOM")) { + FURI_LOG_E(TAG, "CUSTOM preset is not supported"); + break; + // TODO Custom preset loading logic if need + // sub_preset->freq_preset.preset_index = + // subghz_setting_get_inx_preset_by_name(setting, furi_string_get_cstr(temp_str)); + } + + furi_string_set(sub_preset->freq_preset.name, temp_str); + + // Load protocol + ret = SubRemLoadSubStateErrorProtocol; + if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { + FURI_LOG_E(TAG, "Missing Protocol"); + break; + } + + FlipperFormat* fff_data = sub_preset->fff_data; + if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) { + //if RAW + subghz_protocol_raw_gen_fff_data( + fff_data, furi_string_get_cstr(sub_preset->file_path)); + } else { + stream_copy_full( + flipper_format_get_raw_stream(fff_data_file), + flipper_format_get_raw_stream(fff_data)); + } + + if(subghz_txrx_load_decoder_by_name_protocol(txrx, furi_string_get_cstr(temp_str))) { + SubGhzProtocolStatus status = + subghz_protocol_decoder_base_deserialize(subghz_txrx_get_decoder(txrx), fff_data); + if(status != SubGhzProtocolStatusOk) { + break; + } + } else { + FURI_LOG_E(TAG, "Protocol not found"); + break; + } + + const SubGhzProtocol* protocol = subghz_txrx_get_decoder(txrx)->protocol; + + if(protocol->flag & SubGhzProtocolFlag_Send) { + if((protocol->type == SubGhzProtocolTypeStatic) || + (protocol->type == SubGhzProtocolTypeDynamic) || + // TODO: BINRAW It probably works, but checks are needed. + // (protocol->type == SubGhzProtocolTypeBinRAW) || + (protocol->type == SubGhzProtocolTypeRAW)) { + sub_preset->type = protocol->type; + } else { + FURI_LOG_E(TAG, "Unsuported Protocol"); + break; + } + + furi_string_set(sub_preset->protocaol_name, temp_str); + } else { + FURI_LOG_E(TAG, "Protocol does not support transmission"); + break; + } + + if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + + ret = SubRemLoadSubStateOK; + +#if FURI_DEBUG + FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); +#endif + } while(false); + + furi_string_free(temp_str); + return ret; +} diff --git a/applications/main/subghz_remote/helpers/subrem_presets.h b/applications/main/subghz_remote/helpers/subrem_presets.h index 60eedad576..fd4a2d7802 100644 --- a/applications/main/subghz_remote/helpers/subrem_presets.h +++ b/applications/main/subghz_remote/helpers/subrem_presets.h @@ -3,10 +3,12 @@ #include "subrem_types.h" #include #include +#include "../../subghz/helpers/subghz_txrx.h" typedef struct { + FuriString* name; uint32_t frequency; - uint8_t* data; + // size_t preset_index; // Need for custom preset } FreqPreset; // Sub File preset @@ -20,8 +22,17 @@ typedef struct { SubRemLoadSubState load_state; } SubRemSubFilePreset; +typedef struct { + SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; +} SubRemMapPreset; + SubRemSubFilePreset* subrem_sub_file_preset_alloc(); void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset); void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset); + +SubRemLoadSubState subrem_sub_preset_load( + SubRemSubFilePreset* sub_preset, + SubGhzTxRx* txrx, + FlipperFormat* fff_data_file); diff --git a/applications/main/subghz_remote/helpers/subrem_types.h b/applications/main/subghz_remote/helpers/subrem_types.h index 13b42897f6..def8078988 100644 --- a/applications/main/subghz_remote/helpers/subrem_types.h +++ b/applications/main/subghz_remote/helpers/subrem_types.h @@ -26,7 +26,7 @@ typedef enum { } SubRemViewID; typedef enum { - SubRemLoadSubStateNotSet, + SubRemLoadSubStateNotSet = 0, SubRemLoadSubStatePreloaded, SubRemLoadSubStateError, SubRemLoadSubStateErrorNoFile, diff --git a/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c b/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c index ea5c14a0a5..796699c831 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_openmapfile.c @@ -4,7 +4,8 @@ void subrem_scene_openmapfile_on_enter(void* context) { SubGhzRemoteApp* app = context; SubRemLoadMapState load_state = subrem_load_from_file(app); - if(load_state == SubRemLoadMapStateError) { + if(load_state != SubRemLoadMapStateOK && load_state != SubRemLoadMapStateNotAllOK && + load_state != SubRemLoadMapStateBack) { #ifdef SUBREM_LIGHT dialog_message_show_storage_error(app->dialogs, "Can't load\nMap file"); #else diff --git a/applications/main/subghz_remote/scenes/subrem_scene_remote.c b/applications/main/subghz_remote/scenes/subrem_scene_remote.c index 1b8dbc4717..eaa1c41d94 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_remote.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_remote.c @@ -37,17 +37,16 @@ static uint8_t subrem_scene_remote_event_to_index(SubRemCustomEvent event_id) { static bool subrem_scene_remote_update_data_show(void* context) { SubGhzRemoteApp* app = context; - bool ret = false; - subrem_view_remote_add_data_to_show( - app->subrem_remote_view, - furi_string_get_cstr(app->map_preset->subs_preset[0]->label), - furi_string_get_cstr(app->map_preset->subs_preset[1]->label), - furi_string_get_cstr(app->map_preset->subs_preset[2]->label), - furi_string_get_cstr(app->map_preset->subs_preset[3]->label), - furi_string_get_cstr(app->map_preset->subs_preset[4]->label)); + const char* labels[SubRemSubKeyNameMaxCount]; - return ret; + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + labels[i] = furi_string_get_cstr(app->map_preset->subs_preset[i]->label); + } + + subrem_view_remote_add_data_to_show(app->subrem_remote_view, labels); + + return true; } void subrem_scene_remote_on_enter(void* context) { @@ -81,32 +80,37 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { event.event == SubRemCustomEventViewRemoteStartOK) { // Start sending sub subrem_tx_stop_sub(app, true); - app->chusen_sub = subrem_scene_remote_event_to_index(event.event); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateLoading); - if(subrem_tx_start_sub( - app, - app->map_preset->subs_preset[app->chusen_sub], - subrem_scene_remote_raw_callback_end_tx)) { - subrem_view_remote_set_presed_btn(app->subrem_remote_view, app->chusen_sub); + + uint8_t chusen_sub = subrem_scene_remote_event_to_index(event.event); + app->chusen_sub = chusen_sub; + + subrem_view_remote_set_state( + app->subrem_remote_view, SubRemViewRemoteStateLoading, chusen_sub); + + if(subrem_tx_start_sub(app, app->map_preset->subs_preset[chusen_sub])) { + if(app->map_preset->subs_preset[chusen_sub]->type == SubGhzProtocolTypeRAW) { + subghz_txrx_set_raw_file_encoder_worker_callback_end( + app->txrx, subrem_scene_remote_raw_callback_end_tx, app); + } subrem_view_remote_set_state( - app->subrem_remote_view, SubRemViewRemoteStateSending); + app->subrem_remote_view, SubRemViewRemoteStateSending, chusen_sub); notification_message(app->notifications, &sequence_blink_start_magenta); } else { - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + subrem_view_remote_set_state( + app->subrem_remote_view, SubRemViewRemoteStateIdle, 0); notification_message(app->notifications, &sequence_blink_stop); } return true; } else if(event.event == SubRemCustomEventViewRemoteForcedStop) { subrem_tx_stop_sub(app, true); - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle, 0); notification_message(app->notifications, &sequence_blink_stop); return true; } else if(event.event == SubRemCustomEventViewRemoteStop) { if(subrem_tx_stop_sub(app, false)) { - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + subrem_view_remote_set_state( + app->subrem_remote_view, SubRemViewRemoteStateIdle, 0); notification_message(app->notifications, &sequence_blink_stop); } @@ -123,8 +127,7 @@ void subrem_scene_remote_on_exit(void* context) { subrem_tx_stop_sub(app, true); - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle, 0); notification_message(app->notifications, &sequence_blink_stop); } diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index 4f9138e2aa..7383757d25 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -79,23 +79,9 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { app->map_preset->subs_preset[i] = subrem_sub_file_preset_alloc(); } - app->setting = subghz_setting_alloc(); - subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user")); + app->txrx = subghz_txrx_alloc(); - app->environment = subghz_environment_alloc(); - - subghz_environment_load_keystore(app->environment, EXT_PATH("subghz/assets/keeloq_mfcodes")); - subghz_environment_load_keystore( - app->environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user")); - subghz_environment_set_came_atomo_rainbow_table_file_name( - app->environment, EXT_PATH("subghz/assets/came_atomo")); - subghz_environment_set_alutech_at_4n_rainbow_table_file_name( - app->environment, EXT_PATH("subghz/assets/alutech_at_4n")); - subghz_environment_set_nice_flor_s_rainbow_table_file_name( - app->environment, EXT_PATH("subghz/assets/nice_flor_s")); - subghz_environment_set_protocol_registry(app->environment, (void*)&subghz_protocol_registry); - - app->receiver = subghz_receiver_alloc_init(app->environment); + subghz_txrx_set_need_save_callback(app->txrx, subrem_save_active_sub, app); app->tx_running = false; @@ -132,9 +118,7 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { scene_manager_free(app->scene_manager); view_dispatcher_free(app->view_dispatcher); - subghz_receiver_free(app->receiver); - subghz_environment_free(app->environment); - subghz_setting_free(app->setting); + subghz_txrx_free(app->txrx); for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { subrem_sub_file_preset_free(app->map_preset->subs_preset[i]); diff --git a/applications/main/subghz_remote/subghz_remote_app_i.c b/applications/main/subghz_remote/subghz_remote_app_i.c index 9c35a0e036..fb34b59f70 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.c +++ b/applications/main/subghz_remote/subghz_remote_app_i.c @@ -4,6 +4,8 @@ #include +#include "../subghz/helpers/subghz_txrx_i.h" + // #include // #include @@ -11,6 +13,12 @@ #define TAG "SubGhzRemote" +// XXX Using TxRx +// [x] use TxRx preset subrem_sub_preset_load & subrem_tx_start_sub +// [x] subrem_sub_preset_load & drop subrem_set_preset_data +// [x] subrem_tx_start_sub +// [x] subrem_tx_stop_sub + static const char* map_file_labels[SubRemSubKeyNameMaxCount][2] = { [SubRemSubKeyNameUp] = {"UP", "ULABEL"}, [SubRemSubKeyNameDown] = {"DOWN", "DLABEL"}, @@ -19,43 +27,69 @@ static const char* map_file_labels[SubRemSubKeyNameMaxCount][2] = { [SubRemSubKeyNameOk] = {"OK", "OKLABEL"}, }; -static bool - subrem_set_preset_data(SubGhzSetting* setting, FreqPreset* freq_preset, const char* preset) { - const char* preset_name = ""; - if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) { - preset_name = "AM270"; - } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) { - preset_name = "AM650"; - } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) { - preset_name = "FM238"; - } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) { - preset_name = "FM476"; - } else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) { - // preset_name = "CUSTOM"; - return false; - } else { - FURI_LOG_E(TAG, "Unknown preset"); - return false; +static void subrem_map_preset_reset(SubRemMapPreset* map_preset) { + furi_assert(map_preset); + + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + subrem_sub_file_preset_reset(map_preset->subs_preset[i]); } - size_t preset_index = subghz_setting_get_inx_preset_by_name(setting, preset_name); - freq_preset->data = subghz_setting_get_preset_data(setting, preset_index); - return true; } -void subrem_map_preset_reset(SubRemMapPreset* map_preset) { +static SubRemLoadMapState subrem_map_preset_check( + SubRemMapPreset* map_preset, + SubGhzTxRx* txrx, + FlipperFormat* fff_data_file) { furi_assert(map_preset); + furi_assert(txrx); + + bool all_loaded = true; + SubRemLoadMapState ret = SubRemLoadMapStateErrorBrokenFile; + + SubRemLoadSubState sub_preset_loaded; + SubRemSubFilePreset* sub_preset; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - subrem_sub_file_preset_reset(map_preset->subs_preset[i]); + sub_preset = map_preset->subs_preset[i]; + + sub_preset_loaded = SubRemLoadSubStateErrorNoFile; + + if(furi_string_empty(sub_preset->file_path)) { + // FURI_LOG_I(TAG, "Empty file path"); + } else if(!flipper_format_file_open_existing( + fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { + FURI_LOG_W(TAG, "Error open file %s", furi_string_get_cstr(sub_preset->file_path)); + } else { + sub_preset_loaded = subrem_sub_preset_load(sub_preset, txrx, fff_data_file); + } + + // TODO: + // Load file state logic + // Label depending on the state + // Move to remote scene + + if(sub_preset_loaded != SubRemLoadSubStateOK) { + furi_string_set_str(sub_preset->label, "N/A"); + all_loaded = false; + } else { + ret = SubRemLoadMapStateNotAllOK; + } + + if(ret != SubRemLoadMapStateErrorBrokenFile && all_loaded) { + ret = SubRemLoadMapStateOK; + } + + flipper_format_file_close(fff_data_file); } + + return ret; } -static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { - furi_assert(app); +static bool subrem_map_preset_load(SubRemMapPreset* map_preset, FlipperFormat* fff_data_file) { + furi_assert(map_preset); bool ret = false; SubRemSubFilePreset* sub_preset; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - sub_preset = app->map_preset->subs_preset[i]; + sub_preset = map_preset->subs_preset[i]; if(!flipper_format_read_string( fff_data_file, map_file_labels[i][0], sub_preset->file_path)) { #if FURI_DEBUG @@ -69,8 +103,13 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data #if FURI_DEBUG FURI_LOG_W(TAG, "No Label for %s", map_file_labels[i][0]); #endif + // TODO move to remote scene path_extract_filename(sub_preset->file_path, sub_preset->label, true); + ret = true; } else { + ret = true; + } + if(ret) { // Preload seccesful FURI_LOG_I( TAG, @@ -78,154 +117,11 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data map_file_labels[i][0], furi_string_get_cstr(sub_preset->label), furi_string_get_cstr(sub_preset->file_path)); - ret = true; sub_preset->load_state = SubRemLoadSubStatePreloaded; } - flipper_format_rewind(fff_data_file); - } - return ret; -} - -static SubRemLoadMapState - subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { - furi_assert(app); - FuriString* temp_str = furi_string_alloc(); - uint32_t temp_data32; - bool all_loaded = true; - SubRemLoadMapState ret = SubRemLoadMapStateErrorBrokenFile; - SubRemLoadSubState sub_preset_loaded; - SubRemSubFilePreset* sub_preset; - uint32_t repeat = 200; - for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - sub_preset = app->map_preset->subs_preset[i]; - if(furi_string_empty(sub_preset->file_path)) { - // FURI_LOG_I(TAG, "Empty file path"); - continue; - } - - sub_preset_loaded = SubRemLoadSubStateErrorNoFile; - repeat = 200; - do { - if(!flipper_format_file_open_existing( - fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { - FURI_LOG_W(TAG, "Error open file %s", furi_string_get_cstr(sub_preset->file_path)); - break; - } - - if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) { - FURI_LOG_E(TAG, "Missing or incorrect header"); - break; - } - - if(((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) || - (!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) && - temp_data32 == SUBGHZ_KEY_FILE_VERSION) { - } else { - FURI_LOG_E(TAG, "Type or version mismatch"); - break; - } - - //Load frequency - sub_preset_loaded = SubRemLoadSubStateErrorFreq; - if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { - FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); - sub_preset->freq_preset.frequency = - subghz_setting_get_default_frequency(app->setting); - } else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { - FURI_LOG_E(TAG, "This frequency can only be used for RX"); - break; - } else { - sub_preset->freq_preset.frequency = temp_data32; - } - - //Load preset - sub_preset_loaded = SubRemLoadSubStateErrorMod; - if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { - FURI_LOG_E(TAG, "Missing Preset"); - break; - } - - if(!subrem_set_preset_data( - app->setting, &sub_preset->freq_preset, furi_string_get_cstr(temp_str))) { - FURI_LOG_E(TAG, "Cannot load preset."); - break; - } - - //Load protocol - sub_preset_loaded = SubRemLoadSubStateErrorProtocol; - if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { - FURI_LOG_E(TAG, "Missing Protocol"); - break; - } - - FlipperFormat* fff_data = sub_preset->fff_data; - if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) { - //if RAW - subghz_protocol_raw_gen_fff_data( - fff_data, furi_string_get_cstr(sub_preset->file_path)); - } else { - stream_copy_full( - flipper_format_get_raw_stream(fff_data_file), - flipper_format_get_raw_stream(fff_data)); - } - - const SubGhzProtocolRegistry* protocol_registry_items = - subghz_environment_get_protocol_registry(app->environment); - - const SubGhzProtocol* protocol = subghz_protocol_registry_get_by_name( - protocol_registry_items, furi_string_get_cstr(temp_str)); - - if(!protocol) { - FURI_LOG_E(TAG, "Protocol not found"); - break; - } else if(protocol->flag & SubGhzProtocolFlag_Send) { - if((protocol->type == SubGhzProtocolTypeStatic) || - (protocol->type == SubGhzProtocolTypeDynamic) || - // (protocol->type == SubGhzProtocolTypeBinRAW) || // TODO: BINRAW - (protocol->type == SubGhzProtocolTypeRAW)) { - sub_preset->type = protocol->type; - } else { - FURI_LOG_E(TAG, "Unsuported Protocol"); - break; - } - - furi_string_set(sub_preset->protocaol_name, temp_str); - } else { - FURI_LOG_E(TAG, "Protocol does not support transmission"); - } - - if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &repeat, 1)) { - FURI_LOG_E(TAG, "Unable Repeat"); - break; - } - - sub_preset_loaded = SubRemLoadSubStateOK; - ret = SubRemLoadMapStateNotAllOK; - -#if FURI_DEBUG - FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); -#endif - } while(false); - - // TODO: - // Load file state logic - // Label depending on the state - // Move to remote scene - - if(sub_preset_loaded != SubRemLoadSubStateOK) { - furi_string_set_str(sub_preset->label, "N/A"); - all_loaded = false; - } - - if(ret != SubRemLoadMapStateErrorBrokenFile && all_loaded) { - ret = SubRemLoadMapStateOK; - } - - flipper_format_file_close(fff_data_file); + flipper_format_rewind(fff_data_file); } - furi_string_free(temp_str); - return ret; } @@ -247,13 +143,13 @@ SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_p FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); ret = SubRemLoadMapStateErrorOpenError; } else { - if(!subrem_map_preset_load(app, fff_data_file)) { + if(!subrem_map_preset_load(app->map_preset, fff_data_file)) { FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); // ret = // error for popup } else if(!flipper_format_file_close(fff_data_file)) { ret = SubRemLoadMapStateErrorOpenError; } else { - ret = subrem_map_preset_check(app, fff_data_file); + ret = subrem_map_preset_check(app->map_preset, app->txrx, fff_data_file); } } @@ -272,9 +168,9 @@ SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_p return ret; } -bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { +bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* sub_file_name) { furi_assert(flipper_format); - furi_assert(dev_file_name); + furi_assert(sub_file_name); Storage* storage = furi_record_open(RECORD_STORAGE); Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); @@ -283,19 +179,19 @@ bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev uint32_t repeat = 200; FuriString* file_dir = furi_string_alloc(); - path_extract_dirname(dev_file_name, file_dir); + path_extract_dirname(sub_file_name, file_dir); do { // removing additional fields flipper_format_delete_key(flipper_format, "Repeat"); // flipper_format_delete_key(flipper_format, "Manufacture"); - if(!storage_simply_remove(storage, dev_file_name)) { + if(!storage_simply_remove(storage, sub_file_name)) { break; } //ToDo check Write stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); - stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); + stream_save_to_file(flipper_format_stream, storage, sub_file_name, FSOM_CREATE_ALWAYS); if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { FURI_LOG_E(TAG, "Unable Repeat"); @@ -310,10 +206,16 @@ bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev return saved; } -bool subrem_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback) { +void subrem_save_active_sub(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + + SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub]; + subrem_save_protocol_to_file( + sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); +} + +bool subrem_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { furi_assert(app); furi_assert(sub_preset); bool ret = false; @@ -321,88 +223,44 @@ bool subrem_tx_start_sub( subrem_tx_stop_sub(app, true); if(sub_preset->type == SubGhzProtocolTypeUnknown) { - return false; - } - - FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); - - subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); - keeloq_reset_original_btn(); - subghz_custom_btns_reset(); - - do { - flipper_format_rewind(sub_preset->fff_data); // - - app->transmitter = subghz_transmitter_alloc_init( - app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); + ret = false; + } else { + FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); - if(app->transmitter) { - if(subghz_transmitter_deserialize(app->transmitter, sub_preset->fff_data) != - SubGhzProtocolStatusOk) { - FURI_LOG_E(TAG, "Deserialize error!"); - break; - } - furi_hal_subghz_reset(); - furi_hal_subghz_idle(); - furi_hal_subghz_load_custom_preset(sub_preset->freq_preset.data); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); - - furi_hal_subghz_idle(); - - furi_hal_subghz_set_frequency_and_path(sub_preset->freq_preset.frequency); - furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - - if(!furi_hal_subghz_tx()) { - FURI_LOG_E(TAG, "Sending not allowed"); - break; - } + subghz_txrx_load_decoder_by_name_protocol( + app->txrx, furi_string_get_cstr(sub_preset->protocaol_name)); - if(sub_preset->type == SubGhzProtocolTypeRAW) { - subghz_protocol_raw_file_encoder_worker_set_callback_end( - (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( - app->transmitter), - callback, - app); - } + subghz_txrx_set_preset( + app->txrx, + furi_string_get_cstr(sub_preset->freq_preset.name), + sub_preset->freq_preset.frequency, + NULL, + 0); - furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); + subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); + keeloq_reset_original_btn(); + subghz_custom_btns_reset(); + if(subghz_txrx_tx_start(app->txrx, sub_preset->fff_data) == SubGhzTxRxStartTxStateOk) { ret = true; } - } while(false); + } app->tx_running = ret; return ret; } -static void subghz_tx_stop(SubGhzRemoteApp* app) { - furi_assert(app); - - //Stop TX - furi_hal_subghz_stop_async_tx(); - - subghz_transmitter_stop(app->transmitter); - subghz_transmitter_free(app->transmitter); - furi_hal_subghz_idle(); -} - bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { furi_assert(app); SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub]; if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) { - // SubRemSubKeyTypeRawKey)) { + // XXX drop app->tx_running if(app->tx_running) { - subghz_tx_stop(app); + subghz_txrx_stop(app->txrx); if(sub_preset->type == SubGhzProtocolTypeDynamic) { - subrem_save_protocol_to_file( - sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); - keeloq_reset_mfname(); keeloq_reset_kl_type(); keeloq_reset_original_btn(); diff --git a/applications/main/subghz_remote/subghz_remote_app_i.h b/applications/main/subghz_remote/subghz_remote_app_i.h index 5d34968cdc..50e2bae9f8 100644 --- a/applications/main/subghz_remote/subghz_remote_app_i.h +++ b/applications/main/subghz_remote/subghz_remote_app_i.h @@ -3,6 +3,8 @@ #include "helpers/subrem_types.h" #include "helpers/subrem_presets.h" +#include "../subghz/helpers/subghz_txrx.h" + #include #include "views/remote.h" @@ -31,9 +33,6 @@ #define SUBREM_APP_FOLDER EXT_PATH("subghz_remote") #define SUBREM_MAX_LEN_NAME 64 -typedef struct { - SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; -} SubRemMapPreset; typedef struct { Gui* gui; ViewDispatcher* view_dispatcher; @@ -49,10 +48,7 @@ typedef struct { SubRemMapPreset* map_preset; - SubGhzSetting* setting; - SubGhzEnvironment* environment; - SubGhzReceiver* receiver; - SubGhzTransmitter* transmitter; + SubGhzTxRx* txrx; bool tx_running; @@ -61,9 +57,8 @@ typedef struct { SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app); -bool subrem_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback); +bool subrem_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); + +bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced); -bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced); \ No newline at end of file +void subrem_save_active_sub(void* context); \ No newline at end of file diff --git a/applications/main/subghz_remote/views/remote.c b/applications/main/subghz_remote/views/remote.c index 1f867cd0b6..e062f11b1d 100644 --- a/applications/main/subghz_remote/views/remote.c +++ b/applications/main/subghz_remote/views/remote.c @@ -41,24 +41,18 @@ void subrem_view_remote_set_callback( subrem_view_remote->context = context; } -void subrem_view_remote_add_data_to_show( - SubRemViewRemote* subrem_view_remote, - const char* up_label, - const char* down_label, - const char* left_label, - const char* right_label, - const char* ok_label) { +void subrem_view_remote_add_data_to_show(SubRemViewRemote* subrem_view_remote, const char** labels) { furi_assert(subrem_view_remote); with_view_model( subrem_view_remote->view, SubRemViewRemoteModel * model, { - strncpy(model->up_label, up_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->down_label, down_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->left_label, left_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->right_label, right_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->ok_label, ok_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->up_label, labels[0], SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->down_label, labels[1], SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->left_label, labels[2], SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->right_label, labels[3], SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + strncpy(model->ok_label, labels[4], SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); // furi_string_set(model->up_label, up_label); // furi_string_set(model->down_label, down_label); @@ -69,23 +63,21 @@ void subrem_view_remote_add_data_to_show( true); } -void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn) { +void subrem_view_remote_set_state( + SubRemViewRemote* subrem_view_remote, + SubRemViewRemoteState state, + uint8_t presed_btn) { furi_assert(subrem_view_remote); with_view_model( subrem_view_remote->view, SubRemViewRemoteModel * model, - { model->pressed_btn = presed_btn; }, + { + model->state = state; + model->pressed_btn = presed_btn; + }, true); } -void subrem_view_remote_set_state( - SubRemViewRemote* subrem_view_remote, - SubRemViewRemoteState state) { - furi_assert(subrem_view_remote); - with_view_model( - subrem_view_remote->view, SubRemViewRemoteModel * model, { model->state = state; }, true); -} - void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); diff --git a/applications/main/subghz_remote/views/remote.h b/applications/main/subghz_remote/views/remote.h index 76121cf8a0..ea274fca4f 100644 --- a/applications/main/subghz_remote/views/remote.h +++ b/applications/main/subghz_remote/views/remote.h @@ -24,15 +24,9 @@ void subrem_view_remote_free(SubRemViewRemote* subrem_view_remote); View* subrem_view_remote_get_view(SubRemViewRemote* subrem_view_remote); -void subrem_view_remote_add_data_to_show( - SubRemViewRemote* subrem_view_remote, - const char* up_label, - const char* down_label, - const char* left_label, - const char* right_label, - const char* ok_label); +void subrem_view_remote_add_data_to_show(SubRemViewRemote* subrem_view_remote, const char** labels); -void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn); void subrem_view_remote_set_state( SubRemViewRemote* subrem_view_remote, - SubRemViewRemoteState state); \ No newline at end of file + SubRemViewRemoteState state, + uint8_t presed_btn); \ No newline at end of file From 46832ff77f2f67a3b4f1a724dc768ade80d20ca6 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 22 May 2023 02:33:43 +0300 Subject: [PATCH 40/92] gps uart stability fix --- applications/external/gps_nmea_uart/gps_uart.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/applications/external/gps_nmea_uart/gps_uart.c b/applications/external/gps_nmea_uart/gps_uart.c index 4e66aa2843..ada8f04f91 100644 --- a/applications/external/gps_nmea_uart/gps_uart.c +++ b/applications/external/gps_nmea_uart/gps_uart.c @@ -74,11 +74,8 @@ static void gps_uart_parse_nmea(GpsUart* gps_uart, char* line) { static int32_t gps_uart_worker(void* context) { GpsUart* gps_uart = (GpsUart*)context; - gps_uart->rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE * 5, 1); size_t rx_offset = 0; - gps_uart_serial_init(gps_uart); - while(1) { uint32_t events = furi_thread_flags_wait(WORKER_ALL_RX_EVENTS, FuriFlagWaitAny, FuriWaitForever); @@ -148,6 +145,8 @@ void gps_uart_init_thread(GpsUart* gps_uart) { gps_uart->status.time_minutes = 0; gps_uart->status.time_seconds = 0; + gps_uart->rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE * 5, 1); + gps_uart->thread = furi_thread_alloc(); furi_thread_set_name(gps_uart->thread, "GpsUartWorker"); furi_thread_set_stack_size(gps_uart->thread, 1024); @@ -155,6 +154,8 @@ void gps_uart_init_thread(GpsUart* gps_uart) { furi_thread_set_callback(gps_uart->thread, gps_uart_worker); furi_thread_start(gps_uart->thread); + + gps_uart_serial_init(gps_uart); } void gps_uart_deinit_thread(GpsUart* gps_uart) { From ace9e03fe72c921463e94b5570e5fd0753780694 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 22 May 2023 02:54:04 +0300 Subject: [PATCH 41/92] API: Cleanup, mini refactoring of some apps +6k of free flash space --- .../external/esp8266_deauth/esp8266_deauth.c | 18 +- .../external/tetris_game/tetris_game.c | 7 +- .../external/wifi_scanner/wifi_scanner.c | 332 ++++++++++++++---- firmware/targets/f7/api_symbols.csv | 34 +- 4 files changed, 292 insertions(+), 99 deletions(-) diff --git a/applications/external/esp8266_deauth/esp8266_deauth.c b/applications/external/esp8266_deauth/esp8266_deauth.c index fc165b9323..07b7886c89 100644 --- a/applications/external/esp8266_deauth/esp8266_deauth.c +++ b/applications/external/esp8266_deauth/esp8266_deauth.c @@ -154,10 +154,8 @@ static void esp8266_deauth_module_render_callback(Canvas* const canvas, void* ct const char* strInitializing = "Something wrong"; canvas_draw_str( canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strInitializing) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / - 2) /* - (u8g2_GetMaxCharHeight(&canvas->fb) / 2)*/, + (128 / 2) - (canvas_string_width(canvas, strInitializing) / 2), + (64 / 2) /* - (canvas_current_font_height(canvas) / 2)*/, strInitializing); } break; case WaitingForModule: @@ -170,10 +168,8 @@ static void esp8266_deauth_module_render_callback(Canvas* const canvas, void* ct const char* strInitializing = "Attach WiFi Deauther module"; canvas_draw_str( canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strInitializing) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / - 2) /* - (u8g2_GetMaxCharHeight(&canvas->fb) / 2)*/, + (128 / 2) - (canvas_string_width(canvas, strInitializing) / 2), + (64 / 2) /* - (canvas_current_font_height(canvas) / 2)*/, strInitializing); } #endif @@ -188,10 +184,8 @@ static void esp8266_deauth_module_render_callback(Canvas* const canvas, void* ct const char* strInitializing = "Initializing..."; canvas_draw_str( canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strInitializing) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / 2) - - (u8g2_GetMaxCharHeight(&canvas->fb) / 2), + (128 / 2) - (canvas_string_width(canvas, strInitializing) / 2), + (64 / 2) - (canvas_current_font_height(canvas) / 2), strInitializing); } } diff --git a/applications/external/tetris_game/tetris_game.c b/applications/external/tetris_game/tetris_game.c index a569f46d42..5752e1fc3f 100644 --- a/applications/external/tetris_game/tetris_game.c +++ b/applications/external/tetris_game/tetris_game.c @@ -367,11 +367,8 @@ int32_t tetris_game_app() { // Not doing this eventually causes issues with TimerSvc due to not sleeping/yielding enough in this task TaskHandle_t timer_task = xTaskGetHandle(configTIMER_SERVICE_TASK_NAME); - TaskHandle_t curr_task = xTaskGetHandle("Tetris Game"); - uint32_t origTimerPrio = uxTaskPriorityGet(timer_task); - uint32_t myPrio = uxTaskPriorityGet(curr_task); - vTaskPrioritySet(timer_task, myPrio + 1); + vTaskPrioritySet(timer_task, configMAX_PRIORITIES - 1); ViewPort* view_port = view_port_alloc(); view_port_set_orientation(view_port, ViewPortOrientationVertical); @@ -475,7 +472,7 @@ int32_t tetris_game_app() { view_port_free(view_port); furi_message_queue_free(event_queue); furi_mutex_free(tetris_state->mutex); - vTaskPrioritySet(timer_task, origTimerPrio); + vTaskPrioritySet(timer_task, configTIMER_TASK_PRIORITY); free(newPiece); free(tetris_state); diff --git a/applications/external/wifi_scanner/wifi_scanner.c b/applications/external/wifi_scanner/wifi_scanner.c index 341287b544..9dabc6a901 100644 --- a/applications/external/wifi_scanner/wifi_scanner.c +++ b/applications/external/wifi_scanner/wifi_scanner.c @@ -104,6 +104,238 @@ typedef struct SWiFiScannerApp { uint8_t m_animtaionCounter; } SWiFiScannerApp; +/* + Fontname: -FreeType-Inconsolata LGC-Bold-R-Normal--36-360-72-72-P-176-ISO10646-1 + Copyright: Original Roman version created by Raph Levien using his own tools and FontForge. Copyright 2006 Raph Levien. Hellenisation of the Roman font, by Dimosthenis Kaponis, using FontForge. Hellenic glyphs Copyright 2010-2012 Dimosthenis Kaponis. Released under the SIL Open Font License, http://scripts.sil.org/OFL. Cyrillic glyphs added by MihailJP, using FontForge. Cyrillic glyphs Copyright 2012 MihailJP. Released under the SIL Open Font License, http://scripts.sil.org/OFL. Emboldened by MihailJP. Some glyphs modified by Greg Omelaenko, using FontForge. + Glyphs: 95/658 + BBX Build Mode: 2 +*/ +const uint8_t u8g2_font_inb27_mr[4414] = + "_\2\5\4\5\6\1\4\6\26%\0\370\33\371\35\371\5e\13\313\21! \13\266\14\366\207\377\377\377" + "\20\0!\30\266\14\366\7`\310\22\353E\42\351\177r|(\220h\240-\222\17\37\42%\266\14v\37" + "d,\62\310\42\203,\62\310\42\203,\62\310\42\203,\62\310\42\203,\62\310\42\203|\370\377\307\1#" + "M\266\14\366\7u\220\261\310 \213\14\262\310 \213\14\262\310 k\20b\36 \343\1\62\36 \3;" + "d\220E\6Yd\220\65\10Y\203\220\365\306\3c<@\306\3\344\220A\26\31d\221A\326 d\15" + "\62\330 \203\15\62\26!\343\303\63\0$A\266\14\366\7\200H\352\251\325\320;$\220P\14\21d\210" + "C\4\31\1\21AX\11\244e.\271\325\64F\202YD\224E\6Yd\20\23\10\31\244\214AD!" + "&\220P\314Cm\251G$\365\341\42\0%I\266\14\366\7\261\34RN!%\21B\226 \205\14\42" + "H!\203\4b\310H\346!\227N \253\204\22I,\221\222d\10F\302Q\15\221\220N\32\304\220@" + "\6)%\220A\12\21d\20R\304\42\204$R\312)\344\224\17/\3&F\266\14\366\7\264\274\304\326" + "b\251\214\222H!\211\24\222H!\212\14\262\310 \214\4\322\220;\16\65E\302!\202\220A\250A\221" + "\22\310 &\15r\16!\250\224bL)\5\225\7Fa\241\224\64\310\61F|x\30\0'\17\266\14" + "\366\7aH\372\357\303\377\177\1\0((\266\14v\14sD\363\216\63\317@\22\13,\221\304\22\211$" + "\261D\42\351\223ER\262\304\42K,\262\212v\261L\241\1)$\266\14\266\26\263D\233\254\305\42K" + ",\222\310\42\351_$\222\304\22I,\260\304\2\313\263\301\22\307\7\7\0*/\266\14\366\207\207\210\244" + "\261PH\11\205\14\62F\61a\10C\36\30\306\261\2\317C\215\10\262\310(\251\20\202\212!h\234\261" + "\2\12\37\376,\0+\33\266\14\366\207\207\210\244\267\36\30\344\201A\36\30\344\201\261\210\244\337\207\277\14" + "\0,\30\266\14\366\207\377\377\300\220%\32hI\42\307\34rH\42\7\15\15\0-\26\266\14\366\207\177" + "\352\201`\36\10\346\201`\36\10\37\376\277\4\0.\21\266\14\366\207\377\377\0\211\6\332\42\371p\22\0" + "/.\266\14\366\33\223\304\22I,\221H\22\211$\221H\22\211$\221H\22K$\261D\22K$\261" + "D\42I$\222D\42\211\34\65|x\17\0\60I\266\14\366\7\266<\324\324b\251\220\202\210!\247\230" + "b\310)\206\30SJA\204\24\22\10!e\10B\10\31\203\20\62(B\306 \224\30\205\20\22\206!" + "\4\31R\214)\245\34b\312!\247\224r\12)\211-\325\20,\37^\7\61\26\266\14\366\7\226@\363" + "NKL\265!\210\244\377\377\367\341y\0\62'\266\14\366\7\325\70\265Xr\247\24s\306)($\42" + "i\261D\22\13\254\277H\311g\36\10\346\201`\36\10\37\36\6\63-\266\14\366\7\324\70\265Xri" + "\230\222\2\42\222\26\313\63,\265\363RS\261\310\42i) \202\304)\207\224r\36jj\265\363\341y" + "\0\64\65\266\14\366\7\232H\22\13\264\336q\310\215@\32\11\204\21A\330\30d\221A\24!$\221B" + "\22)\4\21C\316\3\203<\60\310\3\203<\60\36\221\364}x\32\0\65*\266\14\366\7\361\235\337!" + "\222N\20\306TK\16\25b\316\70%\5T$\275#P)\4\21cJ\61\17\265\245\234\371\360:\0" + "\66>\266\14\366\7\327\70\265Xj\250\224\221\310\11\211H\22K$\243(\22\22z\347\201`L)\246" + "\234R\10*\205$RH\42\205$R\12\42\206\234b\212!\250\220\202\232b+=\363\341q\0\67-" + "\266\14\366\7\360\201`\36\10\346\201`\236$\261D\22K$\222\304\22I,\221H\22K$\222\304\22" + "I\254\42\211U$\261|\370\4\0\70;\266\14\366\7\325\70\265Xj\250\224r\212!\207\356\24C\20" + ")$\225Q\324b\251)U\204I\244\224C\31\202J!\211\24\222H!\211\224r\212)\245\234\207\232" + "Z\355|x\35\0\71\71\266\14\366\7\265\274\304\326b\251\220\202\210!\247\230b\10\42\206 b\10\42" + "\206 b\312\241L\71\205\30\344\251\23\10\33\203H\42\207$*\34\222D)\251%\266\322+\37>:" + "\27\266\14\366\207\77A\242\201\266H>|\210D\3m\221|\70\11\0;\34\266\14\366\207\77A\242\201" + "\266H>|\210D\3\255X$\221C\222HM\361\1\1< \266\14\366\207\271\60G,\357\264\304\360" + "\265\363J<\20\301\23/\210\301\3\215$T|\370\25\0= \266\14\366\207\317=\60\310\3\203<\60" + "\310\3\343\303\352\3\203<\60\310\3\203<\60>\374g\1>\36\266\14\366\207\266\240D\32\210\37<\261" + "\274\323\20\303\332\325P;\257\304\61\305\207\277\6\0\77%\266\14\266\67N\251\206\236\61\245\34r\312\21" + "\211H*\226Hb\201u\221H\352C\226D\3m\221|x\36\0@G\266\14\366\7\266\274\264\32r" + "\247\230b\10\42\205(B\306Ad\24\65\6ac\20\66\306(\204\214\61H!c\14R\310\30\203\24" + "\62\306\250\306\30m\220\301\310 \213\20R\2!d\222YNH.\265\245\234\371\360\70\0A<\266\14" + "\366\7\67PA\307\34\262\304\2\15<\357\70\22H#\201\264!\10#\203,\62\310\32e(RHj" + "\311\235\357\220S\12I\244\220T\6Yd\220E\6Y%\220F><\13\0BD\266\14\366\7\217)" + "\207\36\10\346\201`\310\61\205\240RH\42\205$RH\42\205\240R\310)\346\201`\336\371@\60\4\225" + "BR!D\21B\24!D\21B\24!$\25B\220!\17\210\362@\60\357\264\17\217\3C/\266\14" + "\366\7\327\264\245\32z\306\24S\312)\244$B\210\22\206\304\22\211\244'K,\222\310\22\213\12\247\240" + "a\214)\346\241\246V\63\37\36\7DC\266\14\366\7o\255\226\336y\207\30c\10*\205\240RH\42" + "\205\244B\210\42\204(B\210\42\204(B\210\42\204(B\210\42\204(B\210\42\204\244BH\42\205\240" + "R\10\42\206\30c\336q\250\245\365\341y\0E'\266\14\366\7\357\1Q\36\20\345\1Q\36\20\205H" + "\372\344;\277C$\375\344\3\242< \312\3\242< ><\14\0F\35\266\14\366\7\360\201`\36\10" + "\346\201`\36\10\206H\372\244C>D$\375\357\303W\0G:\266\14\366\7\326\70\245\32z\306\24S" + "\312)\244$a\210$\261D\42i&\15b\322 &\15b\322(\212\20\242\10!\212\220\222H)\210" + "\24c\212y \34\227\30;\37\36\7HM\266\14\366\7\217$RH\42\205$RH\42\205$RH" + "\42\205$RH\42\205$RH\42\205$R\36\20\345\1Q\36\20\345\1QH\42\205$RH\42\205" + "$RH\42\205$RH\42\205$RH\42\205$RH\42\205$\362\341a\0I\24\266\14\366\7\320" + "!_#\222\376\377k\357\374>\274\14\0J\33\266\14\366\7\264\245\236#\222\376\377\222\60%\215BR" + "S\213\245W>|\1\0KI\266\14\366\7\257\244\62H*\204\240R\310)\206\230rH)\210\24\222" + "\10!\212\14\262\210(\213\204\302RKM\261\22\312\42\203,\62\212\42\244$RH\42\245 b\312!" + "\247\30r\212!\250\24\222\12!\251\20\242\312\207g\1L\32\266\14\366\7\260D\42\351\377\377\311\7D" + "y@\224\7Dy@|x\27\0MU\266\14\366\7\217,\62\310\42\243\244\62J*\303\34\63\314\61" + "\343\224\63N\71\3\33$\214\61\2\31$\320\6\21#\14A\6\21#\14A\6\31eP\243\14\32!" + "\203\220A\310 \213\14\262\310 \213\14\262\310 \213\14\262\310 \213\14\262\310 \213\14\262\310\207g\1" + "NS\266\14\366\7\217(BJ\42\244$B\14\42\304 B\316!\344\34B\220!\204\4R\10!\201" + "\24B\210 \204\22\204P\203\42dP\204\22\204P\202\20RH \204\230\21\10!\6\21r\16!\347" + "\20\202\14!\310\20\222\12!\251\20\242\10!\212|x\27\0OC\266\14\366\7\325\70\265Xr\247\224" + "r\310)\245 RH*\204(\62\212\42\203,\62\310\42\203,\62\310\42\203,\62\310\42\203,\62\212" + "\42\204(BH*\244 b\310)\246\224\202\134bK\71\363\341u\0P\60\266\14\366\7\257\245w\36" + "\10\346\1Q\10*\205\244B\210\42\204(B\210\42\204(BH*\204\240R\36\20\345\201`\34b\212" + "H\372\357\303g\0QJ\266\14\366\7\325\70\265Xr\247\224r\310)\245 RH*\204\244\62\212\42" + "\203,\62\310\42\203,\62\310\42\203,\62\310\42\203,\62\212\42\204\244BH*\244 b\310)\246\224" + "\202\134b+\271\23\211$R\265\344\20\64\37@\0RC\266\14\366\7\217)\207\336y \30rL!" + "\250\24\222H!\211\24\222H!\211\24\202J!\247\230\7\202y\307!\246H!\211\24\222H)\210\30" + "\202\210)\207v\212!\210\30\202J!\211\24\222\312\207w\1S\61\266\14\366\7\365\264\245\32z\207\230" + "\12\211C\222\70DV\321D\364\262\207\242\221ER&,b\302\42e\244B\214)\345\1a^b\354" + "|x\35\0T\27\266\14\366\7\356\1\62\36 \343\1\62\36 \212H\372\377\377>|UH\266\14\366" + "\7\257$B\210\42\204(B\210\42\204(B\210\42\204(B\210\42\204(B\210\42\204(B\210\42\204" + "(B\210\42\204(B\210\42\204(B\210\42\204(B\210\42\244\240B\12*\245\230b\36rJ\71\363" + "\341u\0V>\266\14\366\7\216\60\42\10#\203(B\210\42\204(R\10\42\206 b\10\42\207\30\202" + "\210!\210\30\222H\31\212\20\242\10!\213\214\301\210 \214\10\322H\30\16{\6Z\221H\42\7\25\37" + ">W\134\266\14\366\7n\22\303\15A\212(D\220\62\10\21\244\14B\4!\204\214A\10!\23)c" + "\20\62\312\30\204\10\63\6!\302\10B\210\70\201\20\42N\30f\204!F\30\346\210\21\206\71\342\230#" + "\216\61\304\30C\12*\244\240B\12\42\206 b\10\42\206\240q\206\22H(\201\304\207\247\1XB\266" + "\14\366\7\217(BH\42\206 b\212!\210\224\202\12!\212\214\242\212 \214\204\302\222;\320\300\22K" + "\64\357<\324\24#\202,\62\212\42\204$R\12\42\206\34rJ)\210\24\222\312(\252|x\26\0Y" + "\60\266\14\366\7\216\254\42\212\42\204\244B\12\42\206 b\212!\210\30\202\12!\212\20\242\212 \214\10" + "\322H\30\16\275\363L,\221H\372\357\303\363\0Z\63\266\14\366\7\360\1Q\36\20\345\1Q\36\10\222" + "D\22K\244b\211$\226H\305\22I,\260D\22\13,\261\300\22\37\20\344\201A\36\30\344\201\361\341" + "]\0[\23\266\14\366n\251\227\210\244\377\377\77\331R\357C\10\0\134+\266\14\66\21\262H\42\213$" + "\262H\42\213$\262Hj\22I&\221d\22Id\221D\26Id\221D\26IM\42\311\14\37\36\1" + "]\20\266\14vn\251'\351\377\377_\352\373\220\2^!\266\14\366\7WL\42I\64\357<\324\210 " + "\213\14\262\10!\211\24\222\210!I\34\361\341\377\17\2_\26\266\14\366\207\377\377\247\36 \343\1\62\36" + " \343\1\362!\3\0`\33\266\14\266\11UPA\307$\222\310\22\213,\261\310\42\251\71Q\361\341\377" + "g\0a\60\266\14\366\207\217\236\266\222C.\15S$\325Rj\347\231\7\202)\207\224\202H!\211\24" + "\202J)\345\230\7\202y \34\25H\62\203|x\30\0b;\266\14\66.\221H\372\215\242HH\350" + "\235\7\202\61\305\224rJ!\251\20\222\12!\212\20\242\10!\212\20\242\10!\212\20\222\12)\210\24c" + "Jy \230w\206Hh\220\362\341u\0c(\266\14\366\207\257\32\247\224;\17\4S\225\202\206!I" + "\230\22\211\244\311\42\211,H\240b\310y \34\247\224\63\37\36\7d;\266\14\366\7\207H\372\251\62" + "\10J\201\234g\36\10\245\30S\10*\244\240BH*\204(B\210\42\204(B\210\42\244\240B\12*" + "\245\234R,\363@\70\17\245@T\31\344\303\273\0e,\266\14\366\207\217\236\266TC\317T\206 b" + "H\42\344\201A\36\30\344\201A\36\30\204H\42\253\24\216\61\344<\344\322r\346\303\343\0f\35\266\14" + "\366\7\302\70\265Xj\250\230\201\312\11\211H\312\71\344cD\322\377\367\341\23\0g=\266\14\366\207o" + "\26R\314\3\241< \10!j\224R\16}\247\224r\314(\251\251\265\324\42a\64\42[z \234\7" + "\202y@\20\222\312 \213\14\262\310(\251\214\7Fy \34\267\220\7h<\266\14v.\221H\372\215" + "\242\210@\210\4u\336\71\244\30c\210)\207\30\202\210!\210\30\202\210!\210\30\202\210!\210\30\202\210" + "!\210\30\202\210!\210\30\202\210!\210\30\202\310\207\207\1i\30\266\14\366\7`\310\22+\71>$S" + "\313I\372\277\326R\357\303\323\0j\37\266\14\366\7d\310\22+\71>\364\230\342I\372\377\227\204)\210" + "\220\202\134bK\71\363A\0k\71\266\14v.\221H\372\241R\310)\206\230rH)\210\220\222\310(" + "\212\210\262H(Lck\25Q\24!%\221R\20)\5\21S\16\71\305\20T\12A\206\220d>\274" + "\12\0l\21\266\14vVL'\351\377\377\330;\277\17/\3m@\266\14\366\207\257\221PF!+\234" + "\361\0\31\17\24QF\21\325 \204\10B(A\10%\10\241\4!\224 \204\22\204P\202\20J\20B" + "\11B(A\10%\10\241\4!\224 \204\22\204P\37\236\5n:\266\14\366\207\357\221Q\24\21\10\275" + "\363\316!\305\224CL\71\304\20D\14A\304\20D\14A\304\20D\14A\304\20D\14A\304\20D\14" + "A\304\20D\14A\304\20D><\14\0o\62\266\14\366\207\257\32\247TC\357\224bJ\71\245\220T" + "FIe\220E\6Yd\220E\6Yd\24E\10I\244\224SL)\306<\324\324r\346\303\343\0p" + "=\266\14\366\207\317\221Q\24\11\11=\20\314\3\301\230bJ\71\245\220T\10I\205\20E\10Q\204\20" + "E\10Q\204\20E\10I\205\24D\212\61\245<\20\314;$$DFQD\322\367\301\1q\71\266\14" + "\366\207\217\32AP\12\344<\363@(\305\230BP!\5\25B\24!D\21B\24!D\21B\24!" + "%\221BP)\345\224b\231\7\302y(\5\242\312 \222~\30\0r\37\266\14\366\207\17\22R\22\21" + "\351<\20\314\3\301\34#\216\71\342\224X\42\221\364\277\17\37\1s,\266\14\366\207\217\232\306\222C\317" + "\24C\16A\343\24\24R\211\351)\227\340\221\305\10E\214P\244\224S\312\3\341\270\304\332\371\360:\0" + "t\35\266\14\366\207\234\220\364\332;\277E$\375\223\305\4U\212XL\261\245\232\371\360\66\0u;\266" + "\14\366\207\317\221D\12I\244\220D\12I\244\220D\12I\244\220D\12I\244\220D\12I\244\220D\12" + "I\244\220DJ\71\245\224SL)\306<\20\316C)\20U\6\371\360\60\0v\63\266\14\366\207\257\25" + "E\10Q\204\20E\12I\303\20DL\71\3\21C\20\61$\221\62\24!D\21\62\30\21\204\21A\32" + "\11\303!w\240\201E\22\71>|wH\266\14\366\207\217Q\202\60\42H\31\204\214Q\6!c\224A" + "\310 \243\14j\224A\215\62F\31\303\210Q\206\30a\210QH\230\304($Lb\24\22\204@\306\14" + "s\314\60\307\14sJ)\247\224\202H!\211\24\362\341i\0x\63\266\14\366\207\317\221DJ\71\305\24" + "C\20)D\221QT\21\204%\207\334\201%\232w\36j$\224U\4Q\205\220DJ\71\305\224R\20" + ")$\225\17\357\2y<\266\14\366\207\317\225T\10I\244\220DJA\304\220CC\304\20D\12I\205" + "\20E\310Xd\20F\4aD\14\67\2q\347\35h`\221T$,\24\262\4!L-\325\320+\37" + "\24\0z&\266\14\366\207\357=\20\314\3\301<\20\314\213$\26X\213$\26X\27\13|@\220\7\6" + "y`\220\7\306\207w\1{$\266\14\366\7\342\264\304\324Z\253\300\22\211\244_$\357<\3\15<\262" + "H\372'K,r\255\305\224C\32\0|\16\266\14\366\7\200H\372\377\377\377\357\3}#\266\14\266\66" + "\20\271\324\224,\222\376d\221d\36h\336q\310\221H$\375\213e)\246Xj\347\3\1\0~\31\266" + "\14\366\207/\232\23\214\42d<\60\306\3\303\210\202`\371\360\377\303\0\0\0\0\4\377\377\0"; + +/* + Fontname: open_iconic_arrow_2x + Copyright: https://github.com/iconic/open-iconic, SIL OPEN FONT LICENSE + Glyphs: 28/28 + BBX Build Mode: 0 +*/ +const uint8_t u8g2_font_open_iconic_arrow_2x_t[644] = + "\34\0\4\4\5\5\4\4\6\20\20\0\0\16\0\16\0\0\17\0\0\2g@\17\352i\302$P\376\221" + "\12\64\246\310\11\2A\22O%\303\24Z\360X\242\17^\20\36-<(\0B\22O!\303\32\134\364" + "`\22\17\236\222\35,:\20\0C\17\352)\302$\216\224\31\24\212\4\312\77\2D\37\20\42\302eP" + "\25!\62\205\212\24*a\210#\304E\17\222 F\244P\231\42\245\24\232\2E \20\42\302ePU" + "\11\63E\216\220\71Ah-a\302e\15\241 s\244\310\231\22\246\24\232\2F\37\20\42\302eP\225" + "\211\62G\212\234!\201\310laj\27\221\70C\344H\31\23\245\24\232\2G\37\20\42\302ePU\221" + "\62\205\212\20#A\360haD\34\231(T\244P\31B\244\24\232\2H\21\12.\302C\214\376\215\212" + "$\207\212\15\14\4\0I\23P\341\302\25\134\364`\27\17\36\204xBz\270P\0J\23P\341\302*" + "|\64\221\27\17\36\204px \0U\23\20\42" + "\302\360\201x\230\212&k\22\235J\302\364\14\0V\34\320\241\302\34\36\200\30\27/\204\12\21\32\36\302" + "\240B\204\212x\341F<\200\300\0W\32\220\241\302&\230\354hq\202\304\221\21\306L\14\71A\342D" + "\217%,\14\0X\37\20\42\302\302\210\221@A\2\205K$\314\210\70\42\344\204\30\23$\134BA\2" + "\5q\2\0Y$\17\42\302\34\134\304\270TF\306\214\20\64bH\260\262\203\211\226\34\42$\320\230\21" + "\42H\245+,:\10\0Z\30\220!\303\32\36\200\360\321\4S\61\351\206\324 q\202\4\206\12\17\0" + "[\34\320\241\302`\324X\30q&D-J!&\211\230`a\204\313P\220@A\34\1\0\0\0\4" + "\377\377\0"; + +/* + Fontname: -Adobe-Courier-Bold-R-Normal--11-80-100-100-M-60-ISO10646-1 + Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. + Glyphs: 18/873 + BBX Build Mode: 0 +*/ +const uint8_t u8g2_font_courB08_tn[199] = + "\22\0\3\3\3\4\2\3\4\6\11\0\376\6\376\7\377\0\0\0\0\0\252 \5\0\353\0*\11$\357" + "\212P$\241\0+\12-\353\12\206J\301\20\0,\7\233\345\221$\1-\5\15\357(.\5\212\351\20" + "/\14\304\347K\212\205b\241X\14\0\60\12=\351\231Hx\221L\0\61\10>\351\22\21u\62\62\11" + "=\351\231\250\211\264\34\63\14=\351\231\250I\206\24\311\4\0\64\14>\351\223\215\42ZlB\11\0\65" + "\12=\351\270Q\324F\26\0\66\14=\351\231Hh\24\11E\62\1\67\13=\351\270\310D\62\221L\4" + "\70\15=\351\231H(\222\211\204\42\231\0\71\14=\351\231H(\22\32E\62\1:\6\242\351\20\12\0" + "\0\0\4\377\377\0"; + +/* + Fontname: -Misc-Fixed-Bold-R-Normal--13-120-75-75-C-70-ISO10646-1 + Copyright: Public domain font. Share and enjoy. + Glyphs: 95/1003 + BBX Build Mode: 0 +*/ +const uint8_t u8g2_font_7x13B_tr[1083] = + "_\0\3\3\3\4\3\5\4\6\15\0\376\11\376\11\0\1}\2\330\4\36 \5\0\356\7!\7J\303" + "\307\241D\42\10\235\332\207\204E\0#\20\315\302OR$r\230\244\34&I\221\10\0$\17N\302\227" + "\214\22\321F\223\250Dh\42\0%\17N\302\307H\22\251\4e\212\221JD\64&\17N\302\317H\242" + "\247\221$\62\251\210&\1'\7\42\327\307!\0(\14\314\302\227D$\21\251\211d\2)\15\314\302\207" + "L$\23\251\210$\42\0*\15\66\306O(&:\224d\241\10\0+\13\66\306\227Pt(\11E\0" + ",\10\244\276\317\212\22\0-\6\16\316\207\1.\10\234\276\217\204\42\1/\14N\302\247\232P\246(\23" + "\12\1\60\16N\302\227,\24\21\361$\11\305D\0\61\13N\302\227l\24\21\352\311\0\62\16N\302\17" + "ED\22\212F\62\241\320\0\63\15N\302\207Q\246F\25\222$\24\0\64\15N\302\247lD\221\220H" + "\207\240\2\65\16N\302\307!(\254\210\204B\222\204\2\66\16N\302\17ED\24VDL\22\12\0\67" + "\15N\302\207QM(\23\312\204\62\0\70\16N\302\17E\304$\241\210\230$\24\0\71\16N\302\17E" + "\304$)\12I\22\12\0:\14\304\276\217\204\42\207I(\22\0;\13\304\276\217\204\42\236L\224\0<" + "\10N\302\247LW\35=\7&\312\207\35j>\11N\302\207T\67\35\1\77\16N\302\17ED\22\212" + "fr\230P\4@\17N\302\17%\266R\211L\252\61\11\5\0A\13N\302\17E\304t\30q\22B" + "\14N\302GE\304t\21\61]\0C\13N\302\17ED\324\223\204\2D\12N\302GE\304O\27\0" + "E\13N\302\307!\250X\21*\32F\13N\302\307!\250X\21j\4G\14N\302\17EDT)\61" + "I\12H\13N\302\207\210\323a\304I\0I\11N\302\207I\250O\6J\12N\302\247>\222$\24\0" + "K\17N\302\207lD\221\220f$\211\22-\0L\10N\302\207P\77\32M\13N\302Gpt\70\210" + "x\22N\15N\302\207\210T\251\34&M$\1O\13N\302\17E\304O\22\12\0P\13N\302GE" + "\304t\21j\4Q\14V\276\17E\304S\205\62\241\12R\15N\302GE\304t!I\224h\1S\16" + "N\302\17ED\224R\205$\11\5\0T\11N\302\207I\250\237\0U\12N\302\207\210\77I(\0V" + "\15N\302\207\210I\22\312D\23*\1W\13N\302\207\210\247\303A\64\14X\17N\302Gp$\11\205" + "h\62R\212h\30Y\14N\302\207\210$!\321\204:\1Z\12N\302\207QMG\241\1[\10\314\302" + "\207I\237\10\134\14N\302\207P*\224*J\205\2]\10\314\302\7I\237\14^\11&\326\227\214\42\32" + "\6_\7\26\276\307\241\0`\7\234\336\207L\1a\12\66\302\17Ur\42I\12b\13N\302\207P\261" + "\42\342t\1c\13\66\302\17EDT\222P\0d\12N\302\247\226\23'I\1e\14\66\302\17Et" + "\30\212$\24\0f\14N\302\327H\242(\243\11\265\1g\16F\272\317\22IB\221RD\22\12\0h" + "\13N\302\207P\261\42\342I\0i\12N\302\227P\16\32\352dj\14^\272\247:L\250#IB\1" + "k\15N\302\207P\23EB\42I\224\4l\10N\302\317P\77\31m\12\66\302\207Dr\70\61\11n" + "\11\66\302GE\304\223\0o\12\66\302\17E\304IB\1p\13F\272GE\304t\21*\2q\12F" + "\272\317\211IR\324\0r\11\66\302GED\324\10s\15\66\302\17E$\21KD\22\12\0t\14F" + "\302\217PV\22j\21M\0u\11\66\302\207\210'I\1v\13\66\302\207\210IB\242\211\0w\13\66" + "\302\207\210\351p\11E\0x\14\66\302\207\210$!QD$\1y\14F\272\207\210\223\244H\222P\0" + "z\12\66\302\207Q&\222\11\15{\14\314\302OI&\221ID\262\1|\7J\303\307\3\1}\15\314" + "\302\307L$\221Id\242\12\0~\11\36\332\217\350\20\222\0\0\0\0\4\377\377\0"; + /////// INIT STATE /////// static void wifi_scanner_app_init(SWiFiScannerApp* const app) { app->m_context = Undefined; @@ -153,8 +385,8 @@ int16_t dBmtoPercentage(int16_t dBm) { void DrawSignalStrengthBar(Canvas* canvas, int rssi, int x, int y, int width, int height) { int16_t percents = dBmtoPercentage(rssi); - u8g2_DrawHLine(&canvas->fb, x, y, width); - u8g2_DrawHLine(&canvas->fb, x, y + height, width); + //u8g2_DrawHLine(&canvas->fb, x, y, width); + //u8g2_DrawHLine(&canvas->fb, x, y + height, width); if(rssi != NA && height > 0) { uint8_t barHeight = floor((height / 100.f) * percents); @@ -177,10 +409,8 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { const char* strError = "Something wrong"; canvas_draw_str( canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strError) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / - 2) /* - (u8g2_GetMaxCharHeight(&canvas->fb) / 2)*/, + (128 / 2) - (canvas_string_width(canvas, strError) / 2), + (64 / 2) /* - (canvas_current_font_height(canvas) / 2)*/, strError); } break; case WaitingForModule: @@ -192,10 +422,8 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { const char* strConnectModule = "Attach WiFi scanner module"; canvas_draw_str( canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strConnectModule) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / - 2) /* - (u8g2_GetMaxCharHeight(&canvas->fb) / 2)*/, + (128 / 2) - (canvas_string_width(canvas, strConnectModule) / 2), + (64 / 2) /* - (canvas_current_font_height(canvas) / 2)*/, strConnectModule); } #endif @@ -208,26 +436,19 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { const char* strInitializing = "Initializing..."; canvas_draw_str( canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strInitializing) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / 2) - - (u8g2_GetMaxCharHeight(&canvas->fb) / 2), + (128 / 2) - (canvas_string_width(canvas, strInitializing) / 2), + (64 / 2) - (canvas_current_font_height(canvas) / 2), strInitializing); } } break; case ScanMode: { uint8_t offsetY = 0; uint8_t offsetX = 0; - canvas_draw_frame( - canvas, - 0, - 0, - u8g2_GetDisplayWidth(&canvas->fb), - u8g2_GetDisplayHeight(&canvas->fb)); + canvas_draw_frame(canvas, 0, 0, 128, 64); //canvas_set_font(canvas, FontPrimary); - u8g2_SetFont(&canvas->fb, u8g2_font_7x13B_tr); - uint8_t fontHeight = u8g2_GetMaxCharHeight(&canvas->fb); + canvas_set_custom_u8g2_font(canvas, u8g2_font_7x13B_tr); + uint8_t fontHeight = canvas_current_font_height(canvas); offsetX += 5; offsetY += fontHeight; @@ -248,8 +469,8 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { furi_string_get_cstr(app->m_currentAccesspointDescription.m_bssid)); canvas_set_font(canvas, FontSecondary); - //u8g2_SetFont(&canvas->fb, u8g2_font_tinytim_tf); - fontHeight = u8g2_GetMaxCharHeight(&canvas->fb); + //canvas_set_custom_u8g2_font(canvas, u8g2_font_tinytim_tf); + fontHeight = canvas_current_font_height(canvas); offsetY += fontHeight + 1; @@ -276,24 +497,20 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { offsetY += fontHeight; offsetY -= fontHeight; - u8g2_SetFont(&canvas->fb, u8g2_font_courB08_tn); + canvas_set_custom_u8g2_font(canvas, u8g2_font_courB08_tn); snprintf( string, sizeof(string), "%d/%d", app->m_currentIndexAccessPoint, app->m_totalAccessPoints); - offsetX = u8g2_GetDisplayWidth(&canvas->fb) - canvas_string_width(canvas, string) - 5; + offsetX = 128 - canvas_string_width(canvas, string) - 5; canvas_draw_str(canvas, offsetX, offsetY, string); canvas_draw_frame( - canvas, - offsetX - 6, - offsetY - u8g2_GetMaxCharHeight(&canvas->fb) - 3, - u8g2_GetDisplayWidth(&canvas->fb), - u8g2_GetDisplayHeight(&canvas->fb)); + canvas, offsetX - 6, offsetY - canvas_current_font_height(canvas) - 3, 128, 64); - u8g2_SetFont(&canvas->fb, u8g2_font_open_iconic_arrow_2x_t); + canvas_set_custom_u8g2_font(canvas, u8g2_font_open_iconic_arrow_2x_t); if(app->m_currentIndexAccessPoint != app->m_totalAccessPoints) { //canvas_draw_triangle(canvas, offsetX - 5 - 20, offsetY + 5, 4, 4, CanvasDirectionBottomToTop); canvas_draw_str(canvas, offsetX - 0 - 35, offsetY + 5, "\x4C"); @@ -308,25 +525,21 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { uint8_t offsetY = 0; uint8_t offsetX = 0; - canvas_draw_frame( - canvas, - 0, - 0, - u8g2_GetDisplayWidth(&canvas->fb), - u8g2_GetDisplayHeight(&canvas->fb)); + canvas_draw_frame(canvas, 0, 0, 128, 64); //canvas_set_font(canvas, FontBigNumbers); - u8g2_SetFont(&canvas->fb, u8g2_font_inb27_mr); - uint8_t fontHeight = u8g2_GetMaxCharHeight(&canvas->fb); + //canvas_set_custom_u8g2_font(canvas, u8g2_font_inb27_mr); + canvas_set_custom_u8g2_font(canvas, u8g2_font_inb27_mr); + uint8_t fontHeight = canvas_current_font_height(canvas); uint8_t fontWidth = u8g2_GetMaxCharWidth(&canvas->fb); if(app->m_currentAccesspointDescription.m_rssi == NA) { - offsetX += floor(u8g2_GetDisplayWidth(&canvas->fb) / 2) - fontWidth - 10; + offsetX += floor(128 / 2) - fontWidth - 10; offsetY += fontHeight - 5; canvas_draw_str(canvas, offsetX, offsetY, "N/A"); } else { - offsetX += floor(u8g2_GetDisplayWidth(&canvas->fb) / 2) - 2 * fontWidth; + offsetX += floor(128 / 2) - 2 * fontWidth; offsetY += fontHeight - 5; char rssi[8]; @@ -335,12 +548,12 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { } //canvas_set_font(canvas, FontPrimary); - u8g2_SetFont(&canvas->fb, u8g2_font_7x13B_tr); - fontHeight = u8g2_GetMaxCharHeight(&canvas->fb); + canvas_set_custom_u8g2_font(canvas, u8g2_font_7x13B_tr); + fontHeight = canvas_current_font_height(canvas); fontWidth = u8g2_GetMaxCharWidth(&canvas->fb); offsetX = 5; - offsetY = u8g2_GetDisplayHeight(&canvas->fb) - 7 - fontHeight; + offsetY = 64 - 7 - fontHeight; canvas_draw_str( canvas, offsetX, @@ -358,12 +571,7 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { DrawSignalStrengthBar( canvas, app->m_currentAccesspointDescription.m_rssi, 5, 5, 12, 25); DrawSignalStrengthBar( - canvas, - app->m_currentAccesspointDescription.m_rssi, - u8g2_GetDisplayWidth(&canvas->fb) - 5 - 12, - 5, - 12, - 25); + canvas, app->m_currentAccesspointDescription.m_rssi, 128 - 5 - 12, 5, 12, 25); } break; case ScanAnimation: { uint32_t currentTime = furi_get_tick(); @@ -380,18 +588,15 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { canvas_draw_disc( canvas, offsetX + 30 + 25 * i, - u8g2_GetDisplayHeight(&canvas->fb) / 2 - 7, + 64 / 2 - 7, 5 * (app->m_animtaionCounter == i ? mutliplier : 1)); } - u8g2_SetFont(&canvas->fb, u8g2_font_7x13B_tr); + canvas_set_custom_u8g2_font(canvas, u8g2_font_7x13B_tr); //canvas_set_font(canvas, FontPrimary); const char* message = "Scanning"; canvas_draw_str( - canvas, - u8g2_GetDisplayWidth(&canvas->fb) / 2 - canvas_string_width(canvas, message) / 2, - 55, - message); + canvas, 128 / 2 - canvas_string_width(canvas, message) / 2, 55, message); } break; case MonitorAnimation: { uint32_t currentTime = furi_get_tick(); @@ -407,27 +612,24 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { canvas_draw_disc( canvas, offsetX + 30, - u8g2_GetDisplayHeight(&canvas->fb) / 2 - 7, + 64 / 2 - 7, 5 * (app->m_animtaionCounter == 0 ? mutliplier : 1)); canvas_draw_disc( canvas, offsetX + 55, - u8g2_GetDisplayHeight(&canvas->fb) / 2 - 7, + 64 / 2 - 7, 5 * (app->m_animtaionCounter == 1 ? mutliplier : 1)); canvas_draw_disc( canvas, offsetX + 80, - u8g2_GetDisplayHeight(&canvas->fb) / 2 - 7, + 64 / 2 - 7, 5 * (app->m_animtaionCounter == 0 ? mutliplier : 1)); - u8g2_SetFont(&canvas->fb, u8g2_font_7x13B_tr); + canvas_set_custom_u8g2_font(canvas, u8g2_font_7x13B_tr); //canvas_set_font(canvas, FontPrimary); const char* message = "Monitor Mode"; canvas_draw_str( - canvas, - u8g2_GetDisplayWidth(&canvas->fb) / 2 - canvas_string_width(canvas, message) / 2, - 55, - message); + canvas, 128 / 2 - canvas_string_width(canvas, message) / 2, 55, message); } break; default: break; diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 84d0beda81..937fa57d8d 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -3036,13 +3036,13 @@ Function,-,subghz_protocol_decoder_power_smart_get_hash_data,uint8_t,void* Function,-,subghz_protocol_decoder_power_smart_get_string,void,"void*, FuriString*" Function,-,subghz_protocol_decoder_power_smart_reset,void,void* Function,-,subghz_protocol_decoder_power_smart_serialize,SubGhzProtocolStatus,"void*, FlipperFormat*, SubGhzRadioPreset*" -Function,+,subghz_protocol_decoder_princeton_alloc,void*,SubGhzEnvironment* +Function,-,subghz_protocol_decoder_princeton_alloc,void*,SubGhzEnvironment* Function,-,subghz_protocol_decoder_princeton_deserialize,SubGhzProtocolStatus,"void*, FlipperFormat*" -Function,+,subghz_protocol_decoder_princeton_feed,void,"void*, _Bool, uint32_t" -Function,+,subghz_protocol_decoder_princeton_free,void,void* -Function,+,subghz_protocol_decoder_princeton_get_hash_data,uint8_t,void* -Function,+,subghz_protocol_decoder_princeton_get_string,void,"void*, FuriString*" -Function,+,subghz_protocol_decoder_princeton_reset,void,void* +Function,-,subghz_protocol_decoder_princeton_feed,void,"void*, _Bool, uint32_t" +Function,-,subghz_protocol_decoder_princeton_free,void,void* +Function,-,subghz_protocol_decoder_princeton_get_hash_data,uint8_t,void* +Function,-,subghz_protocol_decoder_princeton_get_string,void,"void*, FuriString*" +Function,-,subghz_protocol_decoder_princeton_reset,void,void* Function,-,subghz_protocol_decoder_princeton_serialize,SubGhzProtocolStatus,"void*, FlipperFormat*, SubGhzRadioPreset*" Function,+,subghz_protocol_decoder_raw_alloc,void*,SubGhzEnvironment* Function,+,subghz_protocol_decoder_raw_deserialize,SubGhzProtocolStatus,"void*, FlipperFormat*" @@ -3261,11 +3261,11 @@ Function,-,subghz_protocol_encoder_power_smart_deserialize,SubGhzProtocolStatus, Function,-,subghz_protocol_encoder_power_smart_free,void,void* Function,-,subghz_protocol_encoder_power_smart_stop,void,void* Function,-,subghz_protocol_encoder_power_smart_yield,LevelDuration,void* -Function,+,subghz_protocol_encoder_princeton_alloc,void*,SubGhzEnvironment* +Function,-,subghz_protocol_encoder_princeton_alloc,void*,SubGhzEnvironment* Function,-,subghz_protocol_encoder_princeton_deserialize,SubGhzProtocolStatus,"void*, FlipperFormat*" -Function,+,subghz_protocol_encoder_princeton_free,void,void* -Function,+,subghz_protocol_encoder_princeton_stop,void,void* -Function,+,subghz_protocol_encoder_princeton_yield,LevelDuration,void* +Function,-,subghz_protocol_encoder_princeton_free,void,void* +Function,-,subghz_protocol_encoder_princeton_stop,void,void* +Function,-,subghz_protocol_encoder_princeton_yield,LevelDuration,void* Function,+,subghz_protocol_encoder_raw_alloc,void*,SubGhzEnvironment* Function,+,subghz_protocol_encoder_raw_deserialize,SubGhzProtocolStatus,"void*, FlipperFormat*" Function,+,subghz_protocol_encoder_raw_free,void,void* @@ -3457,7 +3457,7 @@ Function,-,u8g2_DrawExtendedUTF8,u8g2_uint_t,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, Function,-,u8g2_DrawFilledEllipse,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, uint8_t" Function,-,u8g2_DrawFrame,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" Function,-,u8g2_DrawGlyph,u8g2_uint_t,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, uint16_t" -Function,+,u8g2_DrawHLine,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" +Function,-,u8g2_DrawHLine,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" Function,-,u8g2_DrawHVLine,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, uint8_t" Function,-,u8g2_DrawHorizontalBitmap,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, const uint8_t*" Function,-,u8g2_DrawLine,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" @@ -3493,7 +3493,7 @@ Function,-,u8g2_SetBufferCurrTileRow,void,"u8g2_t*, uint8_t" Function,-,u8g2_SetClipWindow,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" Function,-,u8g2_SetDisplayRotation,void,"u8g2_t*, const u8g2_cb_t*" Function,-,u8g2_SetDrawColor,void,"u8g2_t*, uint8_t" -Function,+,u8g2_SetFont,void,"u8g2_t*, const uint8_t*" +Function,-,u8g2_SetFont,void,"u8g2_t*, const uint8_t*" Function,-,u8g2_SetFontDirection,void,"u8g2_t*, uint8_t" Function,-,u8g2_SetFontMode,void,"u8g2_t*, uint8_t" Function,-,u8g2_SetFontPosBaseline,void,u8g2_t* @@ -4531,7 +4531,7 @@ Function,-,uxTaskGetStackHighWaterMark,UBaseType_t,TaskHandle_t Function,-,uxTaskGetStackHighWaterMark2,uint16_t,TaskHandle_t Function,-,uxTaskGetSystemState,UBaseType_t,"TaskStatus_t*, const UBaseType_t, uint32_t*" Function,-,uxTaskGetTaskNumber,UBaseType_t,TaskHandle_t -Function,+,uxTaskPriorityGet,UBaseType_t,const TaskHandle_t +Function,-,uxTaskPriorityGet,UBaseType_t,const TaskHandle_t Function,-,uxTaskPriorityGetFromISR,UBaseType_t,const TaskHandle_t Function,-,uxTaskResetEventItemValue,TickType_t, Function,-,uxTimerGetReloadMode,UBaseType_t,TimerHandle_t @@ -5234,7 +5234,7 @@ Variable,-,u8g2_font_7x13B_mn,const uint8_t[], Variable,-,u8g2_font_7x13B_mr,const uint8_t[], Variable,-,u8g2_font_7x13B_tf,const uint8_t[], Variable,-,u8g2_font_7x13B_tn,const uint8_t[], -Variable,+,u8g2_font_7x13B_tr,const uint8_t[], +Variable,-,u8g2_font_7x13B_tr,const uint8_t[], Variable,-,u8g2_font_7x13O_mf,const uint8_t[], Variable,-,u8g2_font_7x13O_mn,const uint8_t[], Variable,-,u8g2_font_7x13O_mr,const uint8_t[], @@ -5438,7 +5438,7 @@ Variable,-,u8g2_font_chroma48medium8_8n,const uint8_t[], Variable,-,u8g2_font_chroma48medium8_8r,const uint8_t[], Variable,-,u8g2_font_chroma48medium8_8u,const uint8_t[], Variable,-,u8g2_font_courB08_tf,const uint8_t[], -Variable,+,u8g2_font_courB08_tn,const uint8_t[], +Variable,-,u8g2_font_courB08_tn,const uint8_t[], Variable,-,u8g2_font_courB08_tr,const uint8_t[], Variable,-,u8g2_font_courB10_tf,const uint8_t[], Variable,-,u8g2_font_courB10_tn,const uint8_t[], @@ -5788,7 +5788,7 @@ Variable,-,u8g2_font_inb24_mn,const uint8_t[], Variable,-,u8g2_font_inb24_mr,const uint8_t[], Variable,-,u8g2_font_inb27_mf,const uint8_t[], Variable,-,u8g2_font_inb27_mn,const uint8_t[], -Variable,+,u8g2_font_inb27_mr,const uint8_t[], +Variable,-,u8g2_font_inb27_mr,const uint8_t[], Variable,-,u8g2_font_inb30_mf,const uint8_t[], Variable,-,u8g2_font_inb30_mn,const uint8_t[], Variable,-,u8g2_font_inb30_mr,const uint8_t[], @@ -6265,7 +6265,7 @@ Variable,-,u8g2_font_open_iconic_app_4x_t,const uint8_t[], Variable,-,u8g2_font_open_iconic_app_6x_t,const uint8_t[], Variable,-,u8g2_font_open_iconic_app_8x_t,const uint8_t[], Variable,-,u8g2_font_open_iconic_arrow_1x_t,const uint8_t[], -Variable,+,u8g2_font_open_iconic_arrow_2x_t,const uint8_t[], +Variable,-,u8g2_font_open_iconic_arrow_2x_t,const uint8_t[], Variable,-,u8g2_font_open_iconic_arrow_4x_t,const uint8_t[], Variable,-,u8g2_font_open_iconic_arrow_6x_t,const uint8_t[], Variable,-,u8g2_font_open_iconic_arrow_8x_t,const uint8_t[], From 03d8804209fcc73489430dfa6ab39fa37b5be2ef Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 22 May 2023 03:05:51 +0300 Subject: [PATCH 42/92] More API cleanup --- firmware/targets/f7/api_symbols.csv | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 937fa57d8d..33d37ea522 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1048,12 +1048,12 @@ Function,+,furi_hal_bt_change_app,_Bool,"FuriHalBtProfile, GapEventCallback, voi Function,+,furi_hal_bt_clear_white_list,_Bool, Function,+,furi_hal_bt_dump_state,void,FuriString* Function,+,furi_hal_bt_ensure_c2_mode,_Bool,BleGlueC2Mode -Function,+,furi_hal_bt_get_conn_rssi,uint32_t,uint8_t* +Function,-,furi_hal_bt_get_conn_rssi,uint32_t,uint8_t* Function,-,furi_hal_bt_get_hardfault_info,const FuriHalBtHardfaultInfo*, Function,+,furi_hal_bt_get_key_storage_buff,void,"uint8_t**, uint16_t*" Function,+,furi_hal_bt_get_profile_adv_name,const char*,FuriHalBtProfile Function,+,furi_hal_bt_get_profile_mac_addr,const uint8_t*,FuriHalBtProfile -Function,+,furi_hal_bt_get_profile_pairing_method,GapPairing,FuriHalBtProfile +Function,-,furi_hal_bt_get_profile_pairing_method,GapPairing,FuriHalBtProfile Function,+,furi_hal_bt_get_radio_stack,FuriHalBtStack, Function,+,furi_hal_bt_get_rssi,float, Function,+,furi_hal_bt_get_transmitted_packets,uint32_t, @@ -1416,7 +1416,7 @@ Function,+,furi_hal_subghz_get_rssi,float, Function,+,furi_hal_subghz_get_timestamp_file_names,_Bool, Function,+,furi_hal_subghz_idle,void, Function,-,furi_hal_subghz_init,void, -Function,+,furi_hal_subghz_init_check,_Bool, +Function,-,furi_hal_subghz_init_check,_Bool, Function,+,furi_hal_subghz_init_radio_type,_Bool,SubGhzRadioType Function,+,furi_hal_subghz_is_async_tx_complete,_Bool, Function,+,furi_hal_subghz_is_frequency_valid,_Bool,uint32_t @@ -1436,8 +1436,8 @@ Function,+,furi_hal_subghz_set_external_power_disable,void,_Bool Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath -Function,+,furi_hal_subghz_set_rolling_counter_mult,void,uint8_t -Function,+,furi_hal_subghz_set_timestamp_file_names,void,_Bool +Function,-,furi_hal_subghz_set_rolling_counter_mult,void,uint8_t +Function,-,furi_hal_subghz_set_timestamp_file_names,void,_Bool Function,-,furi_hal_subghz_shutdown,void, Function,+,furi_hal_subghz_sleep,void, Function,+,furi_hal_subghz_start_async_rx,void,"FuriHalSubGhzCaptureCallback, void*" @@ -1654,7 +1654,7 @@ Function,-,gamma,double,double Function,-,gamma_r,double,"double, int*" Function,-,gammaf,float,float Function,-,gammaf_r,float,"float, int*" -Function,+,gap_get_remote_conn_rssi,uint32_t,int8_t* +Function,-,gap_get_remote_conn_rssi,uint32_t,int8_t* Function,-,gap_get_state,GapState, Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*" Function,-,gap_start_advertising,void, From aab4d2bd34fa2a630dc443c8b3d3286f4240704b Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 22 May 2023 03:45:17 +0300 Subject: [PATCH 43/92] API CleanUp part 3 --- applications/external/doom/display.h | 2 +- .../external/esp8266_deauth/esp8266_deauth.c | 6 +- .../external/wifi_scanner/wifi_scanner.c | 6 +- applications/services/gui/application.fam | 1 - applications/services/gui/canvas.c | 5 + applications/services/gui/canvas.h | 8 + firmware/targets/f7/api_symbols.csv | 2901 +---------------- lib/SConscript | 1 - 8 files changed, 20 insertions(+), 2910 deletions(-) diff --git a/applications/external/doom/display.h b/applications/external/doom/display.h index cc9052acc8..9695b5adf9 100644 --- a/applications/external/doom/display.h +++ b/applications/external/doom/display.h @@ -90,7 +90,7 @@ void drawVLine(uint8_t x, int8_t start_y, int8_t end_y, uint8_t intensity, Canva void setupDisplay(Canvas* canvas) { memset(zbuffer, 0xff, 128); - display_buf = (uint8_t*)canvas_get_buffer(canvas); + display_buf = (uint8_t*)canvas->fb.tile_buf_ptr; //display_buf = u8g2_GetBufferPtr(&canvas->fb); } diff --git a/applications/external/esp8266_deauth/esp8266_deauth.c b/applications/external/esp8266_deauth/esp8266_deauth.c index 07b7886c89..e0a966975e 100644 --- a/applications/external/esp8266_deauth/esp8266_deauth.c +++ b/applications/external/esp8266_deauth/esp8266_deauth.c @@ -11,8 +11,6 @@ //#include //#include -#include - #include "FlipperZeroWiFiDeauthModuleDefines.h" #define DEAUTH_APP_DEBUG 0 @@ -192,8 +190,8 @@ static void esp8266_deauth_module_render_callback(Canvas* const canvas, void* ct #endif // ENABLE_MODULE_POWER break; case ModuleActive: { - uint8_t* buffer = canvas_get_buffer(canvas); - app->m_canvasSize = canvas_get_buffer_size(canvas); + uint8_t* buffer = canvas->fb.tile_buf_ptr; + app->m_canvasSize = gui_get_framebuffer_size(app->m_gui); memcpy(buffer, app->m_backBuffer, app->m_canvasSize); } break; default: diff --git a/applications/external/wifi_scanner/wifi_scanner.c b/applications/external/wifi_scanner/wifi_scanner.c index 9dabc6a901..127bee0cd1 100644 --- a/applications/external/wifi_scanner/wifi_scanner.c +++ b/applications/external/wifi_scanner/wifi_scanner.c @@ -11,8 +11,6 @@ #include #include -#include - #include "FlipperZeroWiFiModuleDefines.h" #define WIFI_APP_DEBUG 0 @@ -531,7 +529,7 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { //canvas_set_custom_u8g2_font(canvas, u8g2_font_inb27_mr); canvas_set_custom_u8g2_font(canvas, u8g2_font_inb27_mr); uint8_t fontHeight = canvas_current_font_height(canvas); - uint8_t fontWidth = u8g2_GetMaxCharWidth(&canvas->fb); + uint8_t fontWidth = canvas_current_font_width(canvas); if(app->m_currentAccesspointDescription.m_rssi == NA) { offsetX += floor(128 / 2) - fontWidth - 10; @@ -550,7 +548,7 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { //canvas_set_font(canvas, FontPrimary); canvas_set_custom_u8g2_font(canvas, u8g2_font_7x13B_tr); fontHeight = canvas_current_font_height(canvas); - fontWidth = u8g2_GetMaxCharWidth(&canvas->fb); + fontWidth = canvas_current_font_width(canvas); offsetX = 5; offsetY = 64 - 7 - fontHeight; diff --git a/applications/services/gui/application.fam b/applications/services/gui/application.fam index 193b9dfd3f..869d964dd0 100644 --- a/applications/services/gui/application.fam +++ b/applications/services/gui/application.fam @@ -14,7 +14,6 @@ App( "gui.h", "icon_i.h", "elements.h", - "canvas_i.h", "view_dispatcher.h", "view_stack.h", "modules/button_menu.h", diff --git a/applications/services/gui/canvas.c b/applications/services/gui/canvas.c index 057bd3e95c..0786e8486d 100644 --- a/applications/services/gui/canvas.c +++ b/applications/services/gui/canvas.c @@ -100,6 +100,11 @@ uint8_t canvas_current_font_height(const Canvas* canvas) { return font_height; } +uint8_t canvas_current_font_width(const Canvas* canvas) { + furi_assert(canvas); + return (uint8_t)u8g2_GetMaxCharWidth(&canvas->fb); +} + const CanvasFontParameters* canvas_get_font_params(const Canvas* canvas, Font font) { furi_assert(canvas); furi_assert(font < FontTotalNumber); diff --git a/applications/services/gui/canvas.h b/applications/services/gui/canvas.h index 9d8cf607f7..7a2ae1873d 100644 --- a/applications/services/gui/canvas.h +++ b/applications/services/gui/canvas.h @@ -120,6 +120,14 @@ uint8_t canvas_height(const Canvas* canvas); */ uint8_t canvas_current_font_height(const Canvas* canvas); +/** Get current font width + * + * @param canvas Canvas instance + * + * @return width in pixels. + */ +uint8_t canvas_current_font_width(const Canvas* canvas); + /** Get font parameters * * @param canvas Canvas instance diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 33d37ea522..3313f3ecd8 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -5,7 +5,6 @@ Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, Header,+,applications/services/dialogs/dialogs.h,, Header,+,applications/services/dolphin/dolphin.h,, -Header,+,applications/services/gui/canvas_i.h,, Header,+,applications/services/gui/elements.h,, Header,+,applications/services/gui/gui.h,, Header,+,applications/services/gui/icon_i.h,, @@ -213,7 +212,6 @@ Header,+,lib/toolbox/stream/string_stream.h,, Header,+,lib/toolbox/tar/tar_archive.h,, Header,+,lib/toolbox/value_index.h,, Header,+,lib/toolbox/version.h,, -Header,+,lib/u8g2/u8g2.h,, Function,-,LL_ADC_CommonDeInit,ErrorStatus,ADC_Common_TypeDef* Function,-,LL_ADC_CommonInit,ErrorStatus,"ADC_Common_TypeDef*, const LL_ADC_CommonInitTypeDef*" Function,-,LL_ADC_CommonStructInit,void,LL_ADC_CommonInitTypeDef* @@ -632,6 +630,7 @@ Function,-,calloc,void*,"size_t, size_t" Function,+,canvas_clear,void,Canvas* Function,+,canvas_commit,void,Canvas* Function,+,canvas_current_font_height,uint8_t,const Canvas* +Function,+,canvas_current_font_width,uint8_t,const Canvas* Function,+,canvas_draw_bitmap,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, const uint8_t*" Function,+,canvas_draw_box,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t" Function,+,canvas_draw_circle,void,"Canvas*, uint8_t, uint8_t, uint8_t" @@ -649,17 +648,10 @@ Function,+,canvas_draw_rframe,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, Function,+,canvas_draw_str,void,"Canvas*, uint8_t, uint8_t, const char*" Function,+,canvas_draw_str_aligned,void,"Canvas*, uint8_t, uint8_t, Align, Align, const char*" Function,+,canvas_draw_triangle,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, CanvasDirection" -Function,+,canvas_draw_u8g2_bitmap,void,"u8g2_t*, uint8_t, uint8_t, uint8_t, uint8_t, const uint8_t*, uint8_t" Function,+,canvas_draw_xbm,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, const uint8_t*" -Function,-,canvas_frame_set,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t" -Function,-,canvas_free,void,Canvas* -Function,+,canvas_get_buffer,uint8_t*,Canvas* -Function,+,canvas_get_buffer_size,size_t,const Canvas* Function,+,canvas_get_font_params,const CanvasFontParameters*,"const Canvas*, Font" -Function,-,canvas_get_orientation,CanvasOrientation,const Canvas* Function,+,canvas_glyph_width,uint8_t,"Canvas*, char" Function,+,canvas_height,uint8_t,const Canvas* -Function,-,canvas_init,Canvas*, Function,+,canvas_invert_color,void,Canvas* Function,+,canvas_reset,void,Canvas* Function,+,canvas_set_bitmap_mode,void,"Canvas*, _Bool" @@ -667,7 +659,6 @@ Function,+,canvas_set_color,void,"Canvas*, Color" Function,+,canvas_set_custom_u8g2_font,void,"Canvas*, const uint8_t*" Function,+,canvas_set_font,void,"Canvas*, Font" Function,+,canvas_set_font_direction,void,"Canvas*, CanvasDirection" -Function,-,canvas_set_orientation,void,"Canvas*, CanvasOrientation" Function,+,canvas_string_width,uint16_t,"Canvas*, const char*" Function,+,canvas_width,uint8_t,const Canvas* Function,-,cbrt,double,double @@ -716,13 +707,6 @@ Function,+,composite_api_resolver_add,void,"CompositeApiResolver*, const ElfApiI Function,+,composite_api_resolver_alloc,CompositeApiResolver*, Function,+,composite_api_resolver_free,void,CompositeApiResolver* Function,+,composite_api_resolver_get,const ElfApiInterface*,CompositeApiResolver* -Function,-,compress_alloc,Compress*,uint16_t -Function,-,compress_decode,_Bool,"Compress*, uint8_t*, size_t, uint8_t*, size_t, size_t*" -Function,-,compress_encode,_Bool,"Compress*, uint8_t*, size_t, uint8_t*, size_t, size_t*" -Function,-,compress_free,void,Compress* -Function,-,compress_icon_alloc,CompressIcon*, -Function,-,compress_icon_decode,void,"CompressIcon*, const uint8_t*, uint8_t**" -Function,-,compress_icon_free,void,CompressIcon* Function,-,copysign,double,"double, double" Function,-,copysignf,float,"float, float" Function,-,copysignl,long double,"long double, long double" @@ -2229,7 +2213,7 @@ Function,+,power_get_pubsub,FuriPubSub*,Power* Function,+,power_is_battery_healthy,_Bool,Power* Function,+,power_off,void,Power* Function,+,power_reboot,void,PowerBootMode -Function,+,power_trigger_ui_update,void,Power* +Function,-,power_trigger_ui_update,void,Power* Function,+,powf,float,"float, float" Function,-,powl,long double,"long double, long double" Function,+,pretty_format_bytes_hex_canonical,void,"FuriString*, size_t, const char*, const uint8_t*, size_t" @@ -3419,7 +3403,6 @@ Function,+,text_input_set_header_text,void,"TextInput*, const char*" Function,+,text_input_set_minimum_length,void,"TextInput*, size_t" Function,+,text_input_set_result_callback,void,"TextInput*, TextInputCallback, void*, char*, size_t, _Bool" Function,+,text_input_set_validator,void,"TextInput*, TextInputValidatorCallback, void*" -Function,-,tga_save,void,const char* Function,-,tgamma,double,double Function,-,tgammaf,float,float Function,-,tgammal,long double,long double @@ -3443,1060 +3426,6 @@ Function,-,trunc,double,double Function,-,truncf,float,float Function,-,truncl,long double,long double Function,-,tzset,void, -Function,-,u8g2_AddPolygonXY,void,"u8g2_t*, int16_t, int16_t" -Function,-,u8g2_ClearBuffer,void,u8g2_t* -Function,-,u8g2_ClearDisplay,void,u8g2_t* -Function,-,u8g2_ClearPolygonXY,void, -Function,-,u8g2_DrawBitmap,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, const uint8_t*" -Function,-,u8g2_DrawBox,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" -Function,-,u8g2_DrawCircle,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, uint8_t" -Function,-,u8g2_DrawDisc,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, uint8_t" -Function,-,u8g2_DrawEllipse,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, uint8_t" -Function,-,u8g2_DrawExtUTF8,u8g2_uint_t,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, uint8_t, const uint16_t*, const char*" -Function,-,u8g2_DrawExtendedUTF8,u8g2_uint_t,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, uint8_t, u8g2_kerning_t*, const char*" -Function,-,u8g2_DrawFilledEllipse,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, uint8_t" -Function,-,u8g2_DrawFrame,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" -Function,-,u8g2_DrawGlyph,u8g2_uint_t,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, uint16_t" -Function,-,u8g2_DrawHLine,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" -Function,-,u8g2_DrawHVLine,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, uint8_t" -Function,-,u8g2_DrawHorizontalBitmap,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, const uint8_t*" -Function,-,u8g2_DrawLine,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" -Function,-,u8g2_DrawLog,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8log_t*" -Function,-,u8g2_DrawPixel,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t" -Function,-,u8g2_DrawPolygon,void,u8g2_t* -Function,-,u8g2_DrawRBox,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" -Function,-,u8g2_DrawRFrame,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" -Function,-,u8g2_DrawStr,u8g2_uint_t,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, const char*" -Function,-,u8g2_DrawTriangle,void,"u8g2_t*, int16_t, int16_t, int16_t, int16_t, int16_t, int16_t" -Function,-,u8g2_DrawUTF8,u8g2_uint_t,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, const char*" -Function,-,u8g2_DrawUTF8Line,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, const char*, uint8_t, uint8_t" -Function,-,u8g2_DrawUTF8Lines,u8g2_uint_t,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, const char*" -Function,-,u8g2_DrawVLine,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" -Function,-,u8g2_DrawXBM,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, const uint8_t*" -Function,-,u8g2_DrawXBMP,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, const uint8_t*" -Function,-,u8g2_FirstPage,void,u8g2_t* -Function,-,u8g2_GetFontSize,size_t,const uint8_t* -Function,-,u8g2_GetGlyphWidth,int8_t,"u8g2_t*, uint16_t" -Function,-,u8g2_GetKerning,uint8_t,"u8g2_t*, u8g2_kerning_t*, uint16_t, uint16_t" -Function,-,u8g2_GetKerningByTable,uint8_t,"u8g2_t*, const uint16_t*, uint16_t, uint16_t" -Function,-,u8g2_GetStrWidth,u8g2_long_t,"u8g2_t*, const char*" -Function,-,u8g2_GetStrX,int8_t,"u8g2_t*, const char*" -Function,-,u8g2_GetUTF8Width,u8g2_uint_t,"u8g2_t*, const char*" -Function,-,u8g2_IsAllValidUTF8,uint8_t,"u8g2_t*, const char*" -Function,-,u8g2_IsGlyph,uint8_t,"u8g2_t*, uint16_t" -Function,-,u8g2_IsIntersection,uint8_t,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" -Function,-,u8g2_NextPage,uint8_t,u8g2_t* -Function,-,u8g2_SendBuffer,void,u8g2_t* -Function,-,u8g2_SendF,void,"u8g2_t*, const char*, ..." -Function,-,u8g2_SetBitmapMode,void,"u8g2_t*, uint8_t" -Function,-,u8g2_SetBufferCurrTileRow,void,"u8g2_t*, uint8_t" -Function,-,u8g2_SetClipWindow,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t" -Function,-,u8g2_SetDisplayRotation,void,"u8g2_t*, const u8g2_cb_t*" -Function,-,u8g2_SetDrawColor,void,"u8g2_t*, uint8_t" -Function,-,u8g2_SetFont,void,"u8g2_t*, const uint8_t*" -Function,-,u8g2_SetFontDirection,void,"u8g2_t*, uint8_t" -Function,-,u8g2_SetFontMode,void,"u8g2_t*, uint8_t" -Function,-,u8g2_SetFontPosBaseline,void,u8g2_t* -Function,-,u8g2_SetFontPosBottom,void,u8g2_t* -Function,-,u8g2_SetFontPosCenter,void,u8g2_t* -Function,-,u8g2_SetFontPosTop,void,u8g2_t* -Function,-,u8g2_SetFontRefHeightAll,void,u8g2_t* -Function,-,u8g2_SetFontRefHeightExtendedText,void,u8g2_t* -Function,-,u8g2_SetFontRefHeightText,void,u8g2_t* -Function,-,u8g2_SetMaxClipWindow,void,u8g2_t* -Function,-,u8g2_SetupBitmap,void,"u8g2_t*, const u8g2_cb_t*, uint16_t, uint16_t" -Function,-,u8g2_SetupBuffer,void,"u8g2_t*, uint8_t*, uint8_t, u8g2_draw_ll_hvline_cb, const u8g2_cb_t*" -Function,-,u8g2_SetupBuffer_SDL_128x64,void,"u8g2_t*, const u8g2_cb_t*" -Function,-,u8g2_SetupBuffer_SDL_128x64_1,void,"u8g2_t*, const u8g2_cb_t*" -Function,-,u8g2_SetupBuffer_SDL_128x64_4,void,"u8g2_t*, const u8g2_cb_t*" -Function,-,u8g2_SetupBuffer_TGA_DESC,void,"u8g2_t*, const u8g2_cb_t*" -Function,-,u8g2_SetupBuffer_TGA_LCD,void,"u8g2_t*, const u8g2_cb_t*" -Function,-,u8g2_SetupBuffer_Utf8,void,"u8g2_t*, const u8g2_cb_t*" -Function,-,u8g2_Setup_a2printer_384x240_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_a2printer_384x240_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_a2printer_384x240_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_hx1230_96x68_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_hx1230_96x68_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_hx1230_96x68_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_il3820_296x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_il3820_296x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_il3820_296x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_il3820_v2_296x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_il3820_v2_296x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_il3820_v2_296x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ist3020_erc19264_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ist3020_erc19264_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ist3020_erc19264_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ist7920_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ist7920_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ist7920_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ks0108_128x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ks0108_128x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ks0108_128x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ks0108_erm19264_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ks0108_erm19264_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ks0108_erm19264_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_160x160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_160x160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_160x160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_160x80_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_160x80_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_160x80_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_240x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_240x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_240x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_240x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_240x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_lc7981_240x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ld7032_60x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ld7032_60x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ld7032_60x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ld7032_i2c_60x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ld7032_i2c_60x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ld7032_i2c_60x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ls013b7dh03_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ls013b7dh03_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ls013b7dh03_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ls013b7dh05_144x168_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ls013b7dh05_144x168_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ls013b7dh05_144x168_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ls027b7dh01_400x240_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ls027b7dh01_400x240_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ls027b7dh01_400x240_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_max7219_32x8_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_max7219_32x8_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_max7219_32x8_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_max7219_64x8_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_max7219_64x8_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_max7219_64x8_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_max7219_8x8_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_max7219_8x8_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_max7219_8x8_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_nt7534_tg12864r_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_nt7534_tg12864r_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_nt7534_tg12864r_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_null,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_pcd8544_84x48_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_pcd8544_84x48_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_pcd8544_84x48_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_pcf8812_96x65_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_pcf8812_96x65_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_pcf8812_96x65_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ra8835_320x240_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ra8835_320x240_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ra8835_320x240_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ra8835_nhd_240x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ra8835_nhd_240x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ra8835_nhd_240x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sbn1661_122x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sbn1661_122x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sbn1661_122x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sed1330_240x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sed1330_240x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sed1330_240x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sed1520_122x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sed1520_122x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sed1520_122x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_128x64_noname_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_128x64_noname_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_128x64_noname_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_128x64_vcomh0_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_128x64_vcomh0_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_128x64_vcomh0_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_128x64_winstar_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_128x64_winstar_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_128x64_winstar_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_64x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_64x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_64x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_72x40_wise_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_72x40_wise_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_72x40_wise_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_128x64_noname_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_128x64_noname_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_128x64_noname_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_128x64_vcomh0_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_128x64_vcomh0_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_128x64_vcomh0_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_128x64_winstar_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_128x64_winstar_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_128x64_winstar_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_64x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_64x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_64x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_72x40_wise_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_72x40_wise_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1106_i2c_72x40_wise_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_64x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_64x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_64x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_64x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_64x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_64x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_pimoroni_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_pimoroni_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_pimoroni_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_seeed_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_seeed_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_seeed_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_seeed_96x96_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_seeed_96x96_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_i2c_seeed_96x96_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_pimoroni_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_pimoroni_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_pimoroni_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_seeed_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_seeed_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_seeed_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_seeed_96x96_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_seeed_96x96_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1107_seeed_96x96_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1108_160x160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1108_160x160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1108_160x160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1108_i2c_160x160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1108_i2c_160x160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1108_i2c_160x160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1122_256x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1122_256x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1122_256x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1122_i2c_256x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1122_i2c_256x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_sh1122_i2c_256x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd0323_i2c_os128064_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd0323_i2c_os128064_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd0323_i2c_os128064_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd0323_os128064_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd0323_os128064_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd0323_os128064_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_128x32_adafruit_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_128x32_adafruit_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_128x32_adafruit_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_128x32_noname_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_128x32_noname_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_128x32_noname_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_128x64_adafruit_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_128x64_adafruit_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_128x64_adafruit_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_i2c_128x32_adafruit_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_i2c_128x32_adafruit_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_i2c_128x32_adafruit_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_i2c_128x32_noname_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_i2c_128x32_noname_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_i2c_128x32_noname_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_i2c_128x64_adafruit_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_i2c_128x64_adafruit_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1305_i2c_128x64_adafruit_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x32_univision_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x32_univision_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x32_univision_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x32_winstar_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x32_winstar_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x32_winstar_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x64_alt0_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x64_alt0_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x64_alt0_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x64_noname_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x64_noname_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x64_noname_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x64_vcomh0_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x64_vcomh0_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_128x64_vcomh0_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_48x64_winstar_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_48x64_winstar_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_48x64_winstar_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_64x32_1f_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_64x32_1f_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_64x32_1f_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_64x32_noname_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_64x32_noname_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_64x32_noname_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_64x48_er_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_64x48_er_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_64x48_er_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_72x40_er_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_72x40_er_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_72x40_er_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_96x16_er_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_96x16_er_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_96x16_er_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x32_univision_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x32_univision_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x32_univision_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x32_winstar_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x32_winstar_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x32_winstar_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x64_alt0_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x64_alt0_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x64_alt0_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x64_noname_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x64_noname_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x64_noname_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x64_vcomh0_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x64_vcomh0_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_128x64_vcomh0_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_48x64_winstar_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_48x64_winstar_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_48x64_winstar_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_64x32_1f_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_64x32_1f_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_64x32_1f_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_64x32_noname_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_64x32_noname_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_64x32_noname_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_64x48_er_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_64x48_er_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_64x48_er_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_72x40_er_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_72x40_er_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_72x40_er_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_96x16_er_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_96x16_er_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1306_i2c_96x16_er_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_128x64_noname0_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_128x64_noname0_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_128x64_noname0_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_128x64_noname2_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_128x64_noname2_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_128x64_noname2_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_i2c_128x64_noname0_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_i2c_128x64_noname0_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_i2c_128x64_noname0_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_i2c_128x64_noname2_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_i2c_128x64_noname2_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1309_i2c_128x64_noname2_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1316_128x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1316_128x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1316_128x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1316_i2c_128x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1316_i2c_128x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1316_i2c_128x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1317_96x96_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1317_96x96_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1317_96x96_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1317_i2c_96x96_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1317_i2c_96x96_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1317_i2c_96x96_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_128x96_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_128x96_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_128x96_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_128x96_xcp_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_128x96_xcp_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_128x96_xcp_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_i2c_128x96_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_i2c_128x96_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_i2c_128x96_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_i2c_128x96_xcp_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_i2c_128x96_xcp_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1318_i2c_128x96_xcp_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1322_nhd_128x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1322_nhd_128x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1322_nhd_128x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1322_nhd_256x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1322_nhd_256x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1322_nhd_256x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1325_i2c_nhd_128x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1325_i2c_nhd_128x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1325_i2c_nhd_128x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1325_nhd_128x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1325_nhd_128x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1325_nhd_128x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1326_er_256x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1326_er_256x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1326_er_256x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1326_i2c_er_256x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1326_i2c_er_256x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1326_i2c_er_256x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_ea_w128128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_ea_w128128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_ea_w128128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_ea_w128128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_ea_w128128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_ea_w128128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_midas_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_midas_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_midas_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_seeed_96x96_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_seeed_96x96_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_seeed_96x96_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_visionox_128x96_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_visionox_128x96_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_visionox_128x96_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_ws_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_ws_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_ws_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_ws_96x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_ws_96x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_i2c_ws_96x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_midas_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_midas_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_midas_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_seeed_96x96_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_seeed_96x96_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_seeed_96x96_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_visionox_128x96_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_visionox_128x96_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_visionox_128x96_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_ws_128x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_ws_128x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_ws_128x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_ws_96x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_ws_96x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1327_ws_96x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1329_128x96_noname_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1329_128x96_noname_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1329_128x96_noname_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1606_172x72_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1606_172x72_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1606_172x72_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1607_200x200_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1607_200x200_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1607_200x200_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1607_gd_200x200_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1607_gd_200x200_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1607_gd_200x200_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1607_ws_200x200_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1607_ws_200x200_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_ssd1607_ws_200x200_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7511_avd_320x240_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7511_avd_320x240_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7511_avd_320x240_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx172104_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx172104_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx172104_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx19296_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx19296_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx19296_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx240160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx240160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx240160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256160_alt_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256160_alt_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256160_alt_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256160m_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256160m_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx256160m_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx25664_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx25664_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_jlx25664_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_wo256x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_wo256x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_i2c_wo256x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx172104_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx172104_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx172104_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx19296_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx19296_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx19296_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx240160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx240160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx240160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256160_alt_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256160_alt_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256160_alt_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256160m_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256160m_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx256160m_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx25664_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx25664_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_jlx25664_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_wo256x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_wo256x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75256_wo256x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7528_i2c_nhd_c160100_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7528_i2c_nhd_c160100_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7528_i2c_nhd_c160100_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7528_nhd_c160100_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7528_nhd_c160100_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7528_nhd_c160100_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75320_i2c_jlx320240_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75320_i2c_jlx320240_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75320_i2c_jlx320240_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75320_jlx320240_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75320_jlx320240_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st75320_jlx320240_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_64128n_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_64128n_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_64128n_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_ea_dogm128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_ea_dogm128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_ea_dogm128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_ea_dogm132_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_ea_dogm132_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_ea_dogm132_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_erc12864_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_erc12864_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_erc12864_alt_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_erc12864_alt_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_erc12864_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_jlx12864_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_jlx12864_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_jlx12864_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_lm6059_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_lm6059_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_lm6059_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_lm6063_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_lm6063_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_lm6063_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_lx12864_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_lx12864_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_lx12864_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_nhd_c12832_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_nhd_c12832_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_nhd_c12832_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_nhd_c12864_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_nhd_c12864_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_nhd_c12864_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_zolen_128x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_zolen_128x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7565_zolen_128x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_64x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_64x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_64x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_enh_dg128064_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_enh_dg128064_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_enh_dg128064_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_enh_dg128064i_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_enh_dg128064i_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_enh_dg128064i_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_i2c_64x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_i2c_64x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_i2c_64x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_jlx12864_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_jlx12864_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_jlx12864_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_os12864_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_os12864_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_os12864_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_pi_132x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_pi_132x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7567_pi_132x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7586s_erc240160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7586s_erc240160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7586s_erc240160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7586s_s028hn118a_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7586s_s028hn118a_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7586s_s028hn118a_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7588_i2c_jlx12864_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7588_i2c_jlx12864_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7588_i2c_jlx12864_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7588_jlx12864_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7588_jlx12864_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7588_jlx12864_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_128x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_128x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_128x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_192x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_192x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_192x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_p_128x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_p_128x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_p_128x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_p_192x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_p_192x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_p_192x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_s_128x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_s_128x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_s_128x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_s_192x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_s_192x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_st7920_s_192x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_128x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_128x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_128x64_alt_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_128x64_alt_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_128x64_alt_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_128x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_160x80_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_160x80_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_160x80_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_240x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_240x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_240x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_240x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_240x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_240x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_256x64_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_256x64_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_t6963_256x64_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1601_128x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1601_128x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1601_128x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1601_i2c_128x32_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1601_i2c_128x32_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1601_i2c_128x32_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1604_i2c_jlx19264_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1604_i2c_jlx19264_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1604_i2c_jlx19264_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1604_jlx19264_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1604_jlx19264_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1604_jlx19264_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_240x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_240x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_240x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_erc240120_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_erc240120_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_erc240120_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_erc24064_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_erc24064_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_erc24064_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_i2c_240x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_i2c_240x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_i2c_240x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_i2c_erc240120_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_i2c_erc240120_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_i2c_erc240120_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_i2c_erc24064_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_i2c_erc24064_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1608_i2c_erc24064_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1610_ea_dogxl160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1610_ea_dogxl160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1610_ea_dogxl160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1610_i2c_ea_dogxl160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1610_i2c_ea_dogxl160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1610_i2c_ea_dogxl160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_cg160160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_cg160160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_cg160160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_ea_dogm240_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_ea_dogm240_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_ea_dogm240_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_ea_dogxl240_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_ea_dogxl240_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_ea_dogxl240_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_ew50850_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_ew50850_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_ew50850_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_cg160160_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_cg160160_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_cg160160_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_ea_dogm240_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_ea_dogm240_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_ea_dogm240_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_ea_dogxl240_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_ea_dogxl240_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_ea_dogxl240_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_ew50850_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_ew50850_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1611_i2c_ew50850_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1638_160x128_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1638_160x128_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1638_160x128_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1701_ea_dogs102_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1701_ea_dogs102_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1701_ea_dogs102_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1701_mini12864_1,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1701_mini12864_2,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_Setup_uc1701_mini12864_f,void,"u8g2_t*, const u8g2_cb_t*, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8g2_UpdateDisplay,void,u8g2_t* -Function,-,u8g2_UpdateDisplayArea,void,"u8g2_t*, uint8_t, uint8_t, uint8_t, uint8_t" -Function,-,u8g2_UserInterfaceInputValue,uint8_t,"u8g2_t*, const char*, const char*, uint8_t*, uint8_t, uint8_t, uint8_t, const char*" -Function,-,u8g2_UserInterfaceMessage,uint8_t,"u8g2_t*, const char*, const char*, const char*, const char*" -Function,-,u8g2_UserInterfaceSelectionList,uint8_t,"u8g2_t*, const char*, uint8_t, const char*" -Function,-,u8g2_WriteBufferPBM,void,"u8g2_t*, void (*)(const char*)" -Function,-,u8g2_WriteBufferPBM2,void,"u8g2_t*, void (*)(const char*)" -Function,-,u8g2_WriteBufferXBM,void,"u8g2_t*, void (*)(const char*)" -Function,-,u8g2_WriteBufferXBM2,void,"u8g2_t*, void (*)(const char*)" -Function,-,u8g2_add_vector_x,u8g2_uint_t,"u8g2_uint_t, int8_t, int8_t, uint8_t" -Function,-,u8g2_add_vector_y,u8g2_uint_t,"u8g2_uint_t, int8_t, int8_t, uint8_t" -Function,-,u8g2_draw_l90_r0,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, uint8_t" -Function,-,u8g2_ll_hvline_horizontal_right_lsb,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, uint8_t" -Function,-,u8g2_ll_hvline_vertical_top_lsb,void,"u8g2_t*, u8g2_uint_t, u8g2_uint_t, u8g2_uint_t, uint8_t" -Function,-,u8g2_m_11_6_1,uint8_t*,uint8_t* -Function,-,u8g2_m_11_6_2,uint8_t*,uint8_t* -Function,-,u8g2_m_11_6_f,uint8_t*,uint8_t* -Function,-,u8g2_m_12_12_1,uint8_t*,uint8_t* -Function,-,u8g2_m_12_12_2,uint8_t*,uint8_t* -Function,-,u8g2_m_12_12_f,uint8_t*,uint8_t* -Function,-,u8g2_m_12_2_1,uint8_t*,uint8_t* -Function,-,u8g2_m_12_2_2,uint8_t*,uint8_t* -Function,-,u8g2_m_12_2_f,uint8_t*,uint8_t* -Function,-,u8g2_m_12_8_1,uint8_t*,uint8_t* -Function,-,u8g2_m_12_8_2,uint8_t*,uint8_t* -Function,-,u8g2_m_12_8_f,uint8_t*,uint8_t* -Function,-,u8g2_m_12_9_1,uint8_t*,uint8_t* -Function,-,u8g2_m_12_9_2,uint8_t*,uint8_t* -Function,-,u8g2_m_12_9_f,uint8_t*,uint8_t* -Function,-,u8g2_m_13_8_1,uint8_t*,uint8_t* -Function,-,u8g2_m_13_8_2,uint8_t*,uint8_t* -Function,-,u8g2_m_13_8_f,uint8_t*,uint8_t* -Function,-,u8g2_m_16_12_1,uint8_t*,uint8_t* -Function,-,u8g2_m_16_12_2,uint8_t*,uint8_t* -Function,-,u8g2_m_16_12_f,uint8_t*,uint8_t* -Function,-,u8g2_m_16_16_1,uint8_t*,uint8_t* -Function,-,u8g2_m_16_16_2,uint8_t*,uint8_t* -Function,-,u8g2_m_16_16_f,uint8_t*,uint8_t* -Function,-,u8g2_m_16_4_1,uint8_t*,uint8_t* -Function,-,u8g2_m_16_4_2,uint8_t*,uint8_t* -Function,-,u8g2_m_16_4_f,uint8_t*,uint8_t* -Function,-,u8g2_m_16_8_1,uint8_t*,uint8_t* -Function,-,u8g2_m_16_8_2,uint8_t*,uint8_t* -Function,-,u8g2_m_16_8_f,uint8_t*,uint8_t* -Function,-,u8g2_m_17_4_1,uint8_t*,uint8_t* -Function,-,u8g2_m_17_4_2,uint8_t*,uint8_t* -Function,-,u8g2_m_17_4_f,uint8_t*,uint8_t* -Function,-,u8g2_m_17_8_1,uint8_t*,uint8_t* -Function,-,u8g2_m_17_8_2,uint8_t*,uint8_t* -Function,-,u8g2_m_17_8_f,uint8_t*,uint8_t* -Function,-,u8g2_m_18_21_1,uint8_t*,uint8_t* -Function,-,u8g2_m_18_21_2,uint8_t*,uint8_t* -Function,-,u8g2_m_18_21_f,uint8_t*,uint8_t* -Function,-,u8g2_m_1_1_1,uint8_t*,uint8_t* -Function,-,u8g2_m_1_1_2,uint8_t*,uint8_t* -Function,-,u8g2_m_1_1_f,uint8_t*,uint8_t* -Function,-,u8g2_m_20_10_1,uint8_t*,uint8_t* -Function,-,u8g2_m_20_10_2,uint8_t*,uint8_t* -Function,-,u8g2_m_20_10_f,uint8_t*,uint8_t* -Function,-,u8g2_m_20_13_1,uint8_t*,uint8_t* -Function,-,u8g2_m_20_13_2,uint8_t*,uint8_t* -Function,-,u8g2_m_20_13_f,uint8_t*,uint8_t* -Function,-,u8g2_m_20_16_1,uint8_t*,uint8_t* -Function,-,u8g2_m_20_16_2,uint8_t*,uint8_t* -Function,-,u8g2_m_20_16_f,uint8_t*,uint8_t* -Function,-,u8g2_m_20_20_1,uint8_t*,uint8_t* -Function,-,u8g2_m_20_20_2,uint8_t*,uint8_t* -Function,-,u8g2_m_20_20_f,uint8_t*,uint8_t* -Function,-,u8g2_m_22_13_1,uint8_t*,uint8_t* -Function,-,u8g2_m_22_13_2,uint8_t*,uint8_t* -Function,-,u8g2_m_22_13_f,uint8_t*,uint8_t* -Function,-,u8g2_m_22_9_1,uint8_t*,uint8_t* -Function,-,u8g2_m_22_9_2,uint8_t*,uint8_t* -Function,-,u8g2_m_22_9_f,uint8_t*,uint8_t* -Function,-,u8g2_m_24_12_1,uint8_t*,uint8_t* -Function,-,u8g2_m_24_12_2,uint8_t*,uint8_t* -Function,-,u8g2_m_24_12_f,uint8_t*,uint8_t* -Function,-,u8g2_m_24_4_1,uint8_t*,uint8_t* -Function,-,u8g2_m_24_4_2,uint8_t*,uint8_t* -Function,-,u8g2_m_24_4_f,uint8_t*,uint8_t* -Function,-,u8g2_m_24_8_1,uint8_t*,uint8_t* -Function,-,u8g2_m_24_8_2,uint8_t*,uint8_t* -Function,-,u8g2_m_24_8_f,uint8_t*,uint8_t* -Function,-,u8g2_m_25_25_1,uint8_t*,uint8_t* -Function,-,u8g2_m_25_25_2,uint8_t*,uint8_t* -Function,-,u8g2_m_25_25_f,uint8_t*,uint8_t* -Function,-,u8g2_m_30_15_1,uint8_t*,uint8_t* -Function,-,u8g2_m_30_15_2,uint8_t*,uint8_t* -Function,-,u8g2_m_30_15_f,uint8_t*,uint8_t* -Function,-,u8g2_m_30_16_1,uint8_t*,uint8_t* -Function,-,u8g2_m_30_16_2,uint8_t*,uint8_t* -Function,-,u8g2_m_30_16_f,uint8_t*,uint8_t* -Function,-,u8g2_m_30_20_1,uint8_t*,uint8_t* -Function,-,u8g2_m_30_20_2,uint8_t*,uint8_t* -Function,-,u8g2_m_30_20_f,uint8_t*,uint8_t* -Function,-,u8g2_m_30_8_1,uint8_t*,uint8_t* -Function,-,u8g2_m_30_8_2,uint8_t*,uint8_t* -Function,-,u8g2_m_30_8_f,uint8_t*,uint8_t* -Function,-,u8g2_m_32_16_1,uint8_t*,uint8_t* -Function,-,u8g2_m_32_16_2,uint8_t*,uint8_t* -Function,-,u8g2_m_32_16_f,uint8_t*,uint8_t* -Function,-,u8g2_m_32_20_1,uint8_t*,uint8_t* -Function,-,u8g2_m_32_20_2,uint8_t*,uint8_t* -Function,-,u8g2_m_32_20_f,uint8_t*,uint8_t* -Function,-,u8g2_m_32_4_1,uint8_t*,uint8_t* -Function,-,u8g2_m_32_4_2,uint8_t*,uint8_t* -Function,-,u8g2_m_32_4_f,uint8_t*,uint8_t* -Function,-,u8g2_m_32_8_1,uint8_t*,uint8_t* -Function,-,u8g2_m_32_8_2,uint8_t*,uint8_t* -Function,-,u8g2_m_32_8_f,uint8_t*,uint8_t* -Function,-,u8g2_m_37_16_1,uint8_t*,uint8_t* -Function,-,u8g2_m_37_16_2,uint8_t*,uint8_t* -Function,-,u8g2_m_37_16_f,uint8_t*,uint8_t* -Function,-,u8g2_m_40_30_1,uint8_t*,uint8_t* -Function,-,u8g2_m_40_30_2,uint8_t*,uint8_t* -Function,-,u8g2_m_40_30_f,uint8_t*,uint8_t* -Function,-,u8g2_m_48_17_1,uint8_t*,uint8_t* -Function,-,u8g2_m_48_17_2,uint8_t*,uint8_t* -Function,-,u8g2_m_48_17_f,uint8_t*,uint8_t* -Function,-,u8g2_m_48_30_1,uint8_t*,uint8_t* -Function,-,u8g2_m_48_30_2,uint8_t*,uint8_t* -Function,-,u8g2_m_48_30_f,uint8_t*,uint8_t* -Function,-,u8g2_m_4_1_1,uint8_t*,uint8_t* -Function,-,u8g2_m_4_1_2,uint8_t*,uint8_t* -Function,-,u8g2_m_4_1_f,uint8_t*,uint8_t* -Function,-,u8g2_m_50_30_1,uint8_t*,uint8_t* -Function,-,u8g2_m_50_30_2,uint8_t*,uint8_t* -Function,-,u8g2_m_50_30_f,uint8_t*,uint8_t* -Function,-,u8g2_m_6_8_1,uint8_t*,uint8_t* -Function,-,u8g2_m_6_8_2,uint8_t*,uint8_t* -Function,-,u8g2_m_6_8_f,uint8_t*,uint8_t* -Function,-,u8g2_m_8_16_1,uint8_t*,uint8_t* -Function,-,u8g2_m_8_16_2,uint8_t*,uint8_t* -Function,-,u8g2_m_8_16_f,uint8_t*,uint8_t* -Function,-,u8g2_m_8_1_1,uint8_t*,uint8_t* -Function,-,u8g2_m_8_1_2,uint8_t*,uint8_t* -Function,-,u8g2_m_8_1_f,uint8_t*,uint8_t* -Function,-,u8g2_m_8_4_1,uint8_t*,uint8_t* -Function,-,u8g2_m_8_4_2,uint8_t*,uint8_t* -Function,-,u8g2_m_8_4_f,uint8_t*,uint8_t* -Function,-,u8g2_m_8_6_1,uint8_t*,uint8_t* -Function,-,u8g2_m_8_6_2,uint8_t*,uint8_t* -Function,-,u8g2_m_8_6_f,uint8_t*,uint8_t* -Function,-,u8g2_m_9_5_1,uint8_t*,uint8_t* -Function,-,u8g2_m_9_5_2,uint8_t*,uint8_t* -Function,-,u8g2_m_9_5_f,uint8_t*,uint8_t* -Function,-,u8g_sdl_get_key,int, -Function,-,u8log_Init,void,"u8log_t*, uint8_t, uint8_t, uint8_t*" -Function,-,u8log_SetCallback,void,"u8log_t*, u8log_cb, void*" -Function,-,u8log_SetLineHeightOffset,void,"u8log_t*, int8_t" -Function,-,u8log_SetRedrawMode,void,"u8log_t*, uint8_t" -Function,-,u8log_WriteChar,void,"u8log_t*, uint8_t" -Function,-,u8log_WriteDec16,void,"u8log_t*, uint16_t, uint8_t" -Function,-,u8log_WriteDec8,void,"u8log_t*, uint8_t, uint8_t" -Function,-,u8log_WriteHex16,void,"u8log_t*, uint16_t" -Function,-,u8log_WriteHex32,void,"u8log_t*, uint32_t" -Function,-,u8log_WriteHex8,void,"u8log_t*, uint8_t" -Function,-,u8log_WriteString,void,"u8log_t*, const char*" -Function,-,u8log_u8g2_cb,void,u8log_t* -Function,-,u8log_u8x8_cb,void,u8log_t* -Function,-,u8sl_Next,void,u8sl_t* -Function,-,u8sl_Prev,void,u8sl_t* -Function,-,u8x8_ClearDisplay,void,u8x8_t* -Function,-,u8x8_ClearDisplayWithTile,void,"u8x8_t*, const uint8_t*" -Function,-,u8x8_ClearLine,void,"u8x8_t*, uint8_t" -Function,-,u8x8_ConnectBitmapToU8x8,uint8_t,u8x8_t* -Function,-,u8x8_CopyStringLine,void,"char*, uint8_t, const char*" -Function,-,u8x8_Draw1x2Glyph,void,"u8x8_t*, uint8_t, uint8_t, uint8_t" -Function,-,u8x8_Draw1x2String,uint8_t,"u8x8_t*, uint8_t, uint8_t, const char*" -Function,-,u8x8_Draw1x2UTF8,uint8_t,"u8x8_t*, uint8_t, uint8_t, const char*" -Function,-,u8x8_Draw2x2Glyph,void,"u8x8_t*, uint8_t, uint8_t, uint8_t" -Function,-,u8x8_Draw2x2String,uint8_t,"u8x8_t*, uint8_t, uint8_t, const char*" -Function,-,u8x8_Draw2x2UTF8,uint8_t,"u8x8_t*, uint8_t, uint8_t, const char*" -Function,-,u8x8_DrawGlyph,void,"u8x8_t*, uint8_t, uint8_t, uint8_t" -Function,-,u8x8_DrawLog,void,"u8x8_t*, uint8_t, uint8_t, u8log_t*" -Function,-,u8x8_DrawString,uint8_t,"u8x8_t*, uint8_t, uint8_t, const char*" -Function,-,u8x8_DrawTile,uint8_t,"u8x8_t*, uint8_t, uint8_t, uint8_t, uint8_t*" -Function,-,u8x8_DrawUTF8,uint8_t,"u8x8_t*, uint8_t, uint8_t, const char*" -Function,-,u8x8_DrawUTF8Line,uint8_t,"u8x8_t*, uint8_t, uint8_t, uint8_t, const char*" -Function,-,u8x8_DrawUTF8Lines,uint8_t,"u8x8_t*, uint8_t, uint8_t, uint8_t, const char*" -Function,-,u8x8_FillDisplay,void,u8x8_t* -Function,-,u8x8_GetBitmapPixel,uint8_t,"u8x8_t*, uint16_t, uint16_t" -Function,-,u8x8_GetMenuEvent,uint8_t,u8x8_t* -Function,-,u8x8_GetStringLineCnt,uint8_t,const char* -Function,-,u8x8_GetStringLineStart,const char*,"uint8_t, const char*" -Function,-,u8x8_GetUTF8Len,uint8_t,"u8x8_t*, const char*" -Function,-,u8x8_InitDisplay,void,u8x8_t* -Function,-,u8x8_RefreshDisplay,void,u8x8_t* -Function,-,u8x8_SaveBitmapTGA,void,"u8x8_t*, const char*" -Function,-,u8x8_SendF,void,"u8x8_t*, const char*, ..." -Function,-,u8x8_SetContrast,void,"u8x8_t*, uint8_t" -Function,-,u8x8_SetFlipMode,void,"u8x8_t*, uint8_t" -Function,-,u8x8_SetFont,void,"u8x8_t*, const uint8_t*" -Function,-,u8x8_SetPowerSave,void,"u8x8_t*, uint8_t" -Function,-,u8x8_Setup,void,"u8x8_t*, u8x8_msg_cb, u8x8_msg_cb, u8x8_msg_cb, u8x8_msg_cb" -Function,-,u8x8_SetupBitmap,void,"u8x8_t*, uint16_t, uint16_t" -Function,-,u8x8_SetupDefaults,void,u8x8_t* -Function,-,u8x8_SetupMemory,void,u8x8_t* -Function,-,u8x8_SetupStdio,void,u8x8_t* -Function,-,u8x8_Setup_SDL_128x64,void,u8x8_t* -Function,-,u8x8_Setup_SDL_240x160,void,u8x8_t* -Function,-,u8x8_Setup_TGA_DESC,void,u8x8_t* -Function,-,u8x8_Setup_TGA_LCD,void,u8x8_t* -Function,-,u8x8_Setup_Utf8,void,u8x8_t* -Function,-,u8x8_UserInterfaceInputValue,uint8_t,"u8x8_t*, const char*, const char*, uint8_t*, uint8_t, uint8_t, uint8_t, const char*" -Function,-,u8x8_UserInterfaceMessage,uint8_t,"u8x8_t*, const char*, const char*, const char*, const char*" -Function,-,u8x8_UserInterfaceSelectionList,uint8_t,"u8x8_t*, const char*, uint8_t, const char*" -Function,-,u8x8_ascii_next,uint16_t,"u8x8_t*, uint8_t" -Function,-,u8x8_byte_3wire_sw_spi,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_byte_4wire_sw_spi,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_byte_8bit_6800mode,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_byte_8bit_8080mode,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_byte_EndTransfer,uint8_t,u8x8_t* -Function,-,u8x8_byte_SendByte,uint8_t,"u8x8_t*, uint8_t" -Function,-,u8x8_byte_SendBytes,uint8_t,"u8x8_t*, uint8_t, uint8_t*" -Function,-,u8x8_byte_SetDC,uint8_t,"u8x8_t*, uint8_t" -Function,-,u8x8_byte_StartTransfer,uint8_t,u8x8_t* -Function,-,u8x8_byte_empty,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_byte_ks0108,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_byte_sed1520,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_byte_set_ks0108_cs,void,"u8x8_t*, uint8_t" -Function,-,u8x8_byte_ssd13xx_sw_i2c,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_byte_sw_i2c,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_001,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_011,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_100,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_110,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_EndTransfer,uint8_t,u8x8_t* -Function,-,u8x8_cad_SendArg,uint8_t,"u8x8_t*, uint8_t" -Function,-,u8x8_cad_SendCmd,uint8_t,"u8x8_t*, uint8_t" -Function,-,u8x8_cad_SendData,uint8_t,"u8x8_t*, uint8_t, uint8_t*" -Function,-,u8x8_cad_SendMultipleArg,uint8_t,"u8x8_t*, uint8_t, uint8_t" -Function,-,u8x8_cad_SendSequence,void,"u8x8_t*, const uint8_t*" -Function,-,u8x8_cad_StartTransfer,uint8_t,u8x8_t* -Function,-,u8x8_cad_empty,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_ld7032_i2c,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_ssd13xx_fast_i2c,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_ssd13xx_i2c,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_st75256_i2c,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_st7920_spi,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_uc16xx_i2c,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_cad_vsendf,void,"u8x8_t*, const char*, va_list" -Function,-,u8x8_capture_get_pixel_1,uint8_t,"uint16_t, uint16_t, uint8_t*, uint8_t" -Function,-,u8x8_capture_get_pixel_2,uint8_t,"uint16_t, uint16_t, uint8_t*, uint8_t" -Function,-,u8x8_capture_write_pbm_buffer,void,"uint8_t*, uint8_t, uint8_t, uint8_t (*)(uint16_t, uint16_t, uint8_t*, uint8_t), void (*)(const char*)" -Function,-,u8x8_capture_write_pbm_pre,void,"uint8_t, uint8_t, void (*)(const char*)" -Function,-,u8x8_capture_write_xbm_buffer,void,"uint8_t*, uint8_t, uint8_t, uint8_t (*)(uint16_t, uint16_t, uint8_t*, uint8_t), void (*)(const char*)" -Function,-,u8x8_capture_write_xbm_pre,void,"uint8_t, uint8_t, void (*)(const char*)" -Function,-,u8x8_d_a2printer_384x240,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_helper_display_init,void,u8x8_t* -Function,-,u8x8_d_helper_display_setup_memory,void,"u8x8_t*, const u8x8_display_info_t*" -Function,-,u8x8_d_hx1230_96x68,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_il3820_296x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_il3820_v2_296x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ist3020_erc19264,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ist7920_128x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ks0108_128x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ks0108_erm19264,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_lc7981_160x160,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_lc7981_160x80,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_lc7981_240x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_lc7981_240x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ld7032_60x32,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ls013b7dh03_128x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ls013b7dh05_144x168,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ls027b7dh01_400x240,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_max7219_16x16,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_max7219_32x8,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_max7219_64x8,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_max7219_8x8,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_nt7534_tg12864r,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_null_cb,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_pcd8544_84x48,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_pcf8812_96x65,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ra8835_320x240,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ra8835_nhd_240x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sbn1661_122x32,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sed1330_240x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sed1520_122x32,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1106_128x64_noname,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1106_128x64_vcomh0,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1106_128x64_winstar,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1106_64x32,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1106_72x40_wise,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1107_128x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1107_64x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1107_pimoroni_128x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1107_seeed_128x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1107_seeed_96x96,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1108_160x160,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_sh1122_256x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd0323_os128064,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1305_128x32_adafruit,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1305_128x32_noname,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1305_128x64_adafruit,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_128x32_univision,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_128x32_winstar,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_128x64_alt0,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_128x64_noname,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_128x64_vcomh0,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_48x64_winstar,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_64x32_1f,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_64x32_noname,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_64x48_er,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_72x40_er,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1306_96x16_er,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1309_128x64_noname0,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1309_128x64_noname2,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1316_128x32,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1317_96x96,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1318_128x96,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1318_128x96_xcp,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1322_nhd_128x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1322_nhd_256x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1325_nhd_128x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1326_er_256x32,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1327_ea_w128128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1327_midas_128x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1327_seeed_96x96,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1327_visionox_128x96,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1327_ws_128x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1327_ws_96x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1329_128x96_noname,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1606_172x72,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1607_200x200,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1607_gd_200x200,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1607_v2_200x200,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_ssd1607_ws_200x200,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7511_avd_320x240,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st75256_jlx172104,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st75256_jlx19296,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st75256_jlx240160,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st75256_jlx256128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st75256_jlx256160,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st75256_jlx256160_alt,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st75256_jlx256160m,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st75256_jlx25664,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st75256_wo256x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7528_nhd_c160100,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st75320_jlx320240,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_64128n,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_ea_dogm128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_ea_dogm132,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_erc12864,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_erc12864_alt,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_jlx12864,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_lm6059,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_lm6063,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_lx12864,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_nhd_c12832,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_nhd_c12864,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7565_zolen_128x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7567_64x32,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7567_enh_dg128064,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7567_enh_dg128064i,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7567_jlx12864,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7567_os12864,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7567_pi_132x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7586s_erc240160,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7586s_s028hn118a,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7588_jlx12864,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7920_128x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_st7920_192x32,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_t6963_128x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_t6963_128x64_alt,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_t6963_160x80,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_t6963_240x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_t6963_240x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_t6963_256x64,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1601_128x32,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1604_jlx19264,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1608_240x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1608_erc240120,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1608_erc24064,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1610_ea_dogxl160,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1611_cg160160,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1611_ea_dogm240,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1611_ea_dogxl240,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1611_ew50850,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1617_jlx128128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1638_160x128,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1701_ea_dogs102,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_d_uc1701_mini12864,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_dummy_cb,uint8_t,"u8x8_t*, uint8_t, uint8_t, void*" -Function,-,u8x8_gpio_call,void,"u8x8_t*, uint8_t, uint8_t" -Function,-,u8x8_u16toa,const char*,"uint16_t, uint8_t" -Function,-,u8x8_u8toa,const char*,"uint8_t, uint8_t" -Function,-,u8x8_upscale_byte,uint16_t,uint8_t -Function,-,u8x8_utf8_init,void,u8x8_t* -Function,-,u8x8_utf8_next,uint16_t,"u8x8_t*, uint8_t" -Function,-,u8x8_utoa,const char*,uint16_t Function,-,uECC_compress,void,"const uint8_t*, uint8_t*, uECC_Curve" Function,+,uECC_compute_public_key,int,"const uint8_t*, uint8_t*, uECC_Curve" Function,-,uECC_curve_private_key_size,int,uECC_Curve @@ -4523,7 +3452,6 @@ Function,-,ulTaskGetIdleRunTimePercent,uint32_t, Function,-,ungetc,int,"int, FILE*" Function,-,unsetenv,int,const char* Function,-,usbd_poll,void,usbd_device* -Function,-,utf8_show,void, Function,-,utoa,char*,"unsigned, char*, int" Function,-,uxListRemove,UBaseType_t,ListItem_t* Function,-,uxTaskGetNumberOfTasks,UBaseType_t, @@ -5150,1831 +4078,6 @@ Variable,-,subghz_protocol_star_line,const SubGhzProtocol, Variable,-,subghz_protocol_star_line_decoder,const SubGhzProtocolDecoder, Variable,-,subghz_protocol_star_line_encoder,const SubGhzProtocolEncoder, Variable,-,suboptarg,char*, -Variable,-,u8g2_cb_mirror,const u8g2_cb_t, -Variable,-,u8g2_cb_r0,const u8g2_cb_t, -Variable,-,u8g2_cb_r1,const u8g2_cb_t, -Variable,-,u8g2_cb_r2,const u8g2_cb_t, -Variable,-,u8g2_cb_r3,const u8g2_cb_t, -Variable,-,u8g2_font_10x20_me,const uint8_t[], -Variable,-,u8g2_font_10x20_mf,const uint8_t[], -Variable,-,u8g2_font_10x20_mn,const uint8_t[], -Variable,-,u8g2_font_10x20_mr,const uint8_t[], -Variable,-,u8g2_font_10x20_t_arabic,const uint8_t[], -Variable,-,u8g2_font_10x20_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_10x20_t_greek,const uint8_t[], -Variable,-,u8g2_font_10x20_te,const uint8_t[], -Variable,-,u8g2_font_10x20_tf,const uint8_t[], -Variable,-,u8g2_font_10x20_tn,const uint8_t[], -Variable,-,u8g2_font_10x20_tr,const uint8_t[], -Variable,-,u8g2_font_4x6_mf,const uint8_t[], -Variable,-,u8g2_font_4x6_mn,const uint8_t[], -Variable,-,u8g2_font_4x6_mr,const uint8_t[], -Variable,-,u8g2_font_4x6_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_4x6_tf,const uint8_t[], -Variable,-,u8g2_font_4x6_tn,const uint8_t[], -Variable,-,u8g2_font_4x6_tr,const uint8_t[], -Variable,-,u8g2_font_5x7_mf,const uint8_t[], -Variable,-,u8g2_font_5x7_mn,const uint8_t[], -Variable,-,u8g2_font_5x7_mr,const uint8_t[], -Variable,-,u8g2_font_5x7_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_5x7_tf,const uint8_t[], -Variable,-,u8g2_font_5x7_tn,const uint8_t[], -Variable,-,u8g2_font_5x7_tr,const uint8_t[], -Variable,-,u8g2_font_5x8_mf,const uint8_t[], -Variable,-,u8g2_font_5x8_mn,const uint8_t[], -Variable,-,u8g2_font_5x8_mr,const uint8_t[], -Variable,-,u8g2_font_5x8_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_5x8_tf,const uint8_t[], -Variable,-,u8g2_font_5x8_tn,const uint8_t[], -Variable,-,u8g2_font_5x8_tr,const uint8_t[], -Variable,-,u8g2_font_6x10_mf,const uint8_t[], -Variable,-,u8g2_font_6x10_mn,const uint8_t[], -Variable,-,u8g2_font_6x10_mr,const uint8_t[], -Variable,-,u8g2_font_6x10_tf,const uint8_t[], -Variable,-,u8g2_font_6x10_tn,const uint8_t[], -Variable,-,u8g2_font_6x10_tr,const uint8_t[], -Variable,-,u8g2_font_6x12_m_symbols,const uint8_t[], -Variable,-,u8g2_font_6x12_me,const uint8_t[], -Variable,-,u8g2_font_6x12_mf,const uint8_t[], -Variable,-,u8g2_font_6x12_mn,const uint8_t[], -Variable,-,u8g2_font_6x12_mr,const uint8_t[], -Variable,-,u8g2_font_6x12_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_6x12_t_symbols,const uint8_t[], -Variable,-,u8g2_font_6x12_te,const uint8_t[], -Variable,-,u8g2_font_6x12_tf,const uint8_t[], -Variable,-,u8g2_font_6x12_tn,const uint8_t[], -Variable,-,u8g2_font_6x12_tr,const uint8_t[], -Variable,-,u8g2_font_6x13B_mf,const uint8_t[], -Variable,-,u8g2_font_6x13B_mn,const uint8_t[], -Variable,-,u8g2_font_6x13B_mr,const uint8_t[], -Variable,-,u8g2_font_6x13B_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_6x13B_t_hebrew,const uint8_t[], -Variable,-,u8g2_font_6x13B_tf,const uint8_t[], -Variable,-,u8g2_font_6x13B_tn,const uint8_t[], -Variable,-,u8g2_font_6x13B_tr,const uint8_t[], -Variable,-,u8g2_font_6x13O_mf,const uint8_t[], -Variable,-,u8g2_font_6x13O_mn,const uint8_t[], -Variable,-,u8g2_font_6x13O_mr,const uint8_t[], -Variable,-,u8g2_font_6x13O_tf,const uint8_t[], -Variable,-,u8g2_font_6x13O_tn,const uint8_t[], -Variable,-,u8g2_font_6x13O_tr,const uint8_t[], -Variable,-,u8g2_font_6x13_me,const uint8_t[], -Variable,-,u8g2_font_6x13_mf,const uint8_t[], -Variable,-,u8g2_font_6x13_mn,const uint8_t[], -Variable,-,u8g2_font_6x13_mr,const uint8_t[], -Variable,-,u8g2_font_6x13_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_6x13_t_hebrew,const uint8_t[], -Variable,-,u8g2_font_6x13_te,const uint8_t[], -Variable,-,u8g2_font_6x13_tf,const uint8_t[], -Variable,-,u8g2_font_6x13_tn,const uint8_t[], -Variable,-,u8g2_font_6x13_tr,const uint8_t[], -Variable,-,u8g2_font_7Segments_26x42_mn,const uint8_t[], -Variable,-,u8g2_font_7x13B_mf,const uint8_t[], -Variable,-,u8g2_font_7x13B_mn,const uint8_t[], -Variable,-,u8g2_font_7x13B_mr,const uint8_t[], -Variable,-,u8g2_font_7x13B_tf,const uint8_t[], -Variable,-,u8g2_font_7x13B_tn,const uint8_t[], -Variable,-,u8g2_font_7x13B_tr,const uint8_t[], -Variable,-,u8g2_font_7x13O_mf,const uint8_t[], -Variable,-,u8g2_font_7x13O_mn,const uint8_t[], -Variable,-,u8g2_font_7x13O_mr,const uint8_t[], -Variable,-,u8g2_font_7x13O_tf,const uint8_t[], -Variable,-,u8g2_font_7x13O_tn,const uint8_t[], -Variable,-,u8g2_font_7x13O_tr,const uint8_t[], -Variable,-,u8g2_font_7x13_m_symbols,const uint8_t[], -Variable,-,u8g2_font_7x13_me,const uint8_t[], -Variable,-,u8g2_font_7x13_mf,const uint8_t[], -Variable,-,u8g2_font_7x13_mn,const uint8_t[], -Variable,-,u8g2_font_7x13_mr,const uint8_t[], -Variable,-,u8g2_font_7x13_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_7x13_t_symbols,const uint8_t[], -Variable,-,u8g2_font_7x13_te,const uint8_t[], -Variable,-,u8g2_font_7x13_tf,const uint8_t[], -Variable,-,u8g2_font_7x13_tn,const uint8_t[], -Variable,-,u8g2_font_7x13_tr,const uint8_t[], -Variable,-,u8g2_font_7x14B_mf,const uint8_t[], -Variable,-,u8g2_font_7x14B_mn,const uint8_t[], -Variable,-,u8g2_font_7x14B_mr,const uint8_t[], -Variable,-,u8g2_font_7x14B_tf,const uint8_t[], -Variable,-,u8g2_font_7x14B_tn,const uint8_t[], -Variable,-,u8g2_font_7x14B_tr,const uint8_t[], -Variable,-,u8g2_font_7x14_mf,const uint8_t[], -Variable,-,u8g2_font_7x14_mn,const uint8_t[], -Variable,-,u8g2_font_7x14_mr,const uint8_t[], -Variable,-,u8g2_font_7x14_tf,const uint8_t[], -Variable,-,u8g2_font_7x14_tn,const uint8_t[], -Variable,-,u8g2_font_7x14_tr,const uint8_t[], -Variable,-,u8g2_font_8x13B_mf,const uint8_t[], -Variable,-,u8g2_font_8x13B_mn,const uint8_t[], -Variable,-,u8g2_font_8x13B_mr,const uint8_t[], -Variable,-,u8g2_font_8x13B_tf,const uint8_t[], -Variable,-,u8g2_font_8x13B_tn,const uint8_t[], -Variable,-,u8g2_font_8x13B_tr,const uint8_t[], -Variable,-,u8g2_font_8x13O_mf,const uint8_t[], -Variable,-,u8g2_font_8x13O_mn,const uint8_t[], -Variable,-,u8g2_font_8x13O_mr,const uint8_t[], -Variable,-,u8g2_font_8x13O_tf,const uint8_t[], -Variable,-,u8g2_font_8x13O_tn,const uint8_t[], -Variable,-,u8g2_font_8x13O_tr,const uint8_t[], -Variable,-,u8g2_font_8x13_m_symbols,const uint8_t[], -Variable,-,u8g2_font_8x13_me,const uint8_t[], -Variable,-,u8g2_font_8x13_mf,const uint8_t[], -Variable,-,u8g2_font_8x13_mn,const uint8_t[], -Variable,-,u8g2_font_8x13_mr,const uint8_t[], -Variable,-,u8g2_font_8x13_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_8x13_t_symbols,const uint8_t[], -Variable,-,u8g2_font_8x13_te,const uint8_t[], -Variable,-,u8g2_font_8x13_tf,const uint8_t[], -Variable,-,u8g2_font_8x13_tn,const uint8_t[], -Variable,-,u8g2_font_8x13_tr,const uint8_t[], -Variable,-,u8g2_font_9x15B_mf,const uint8_t[], -Variable,-,u8g2_font_9x15B_mn,const uint8_t[], -Variable,-,u8g2_font_9x15B_mr,const uint8_t[], -Variable,-,u8g2_font_9x15B_tf,const uint8_t[], -Variable,-,u8g2_font_9x15B_tn,const uint8_t[], -Variable,-,u8g2_font_9x15B_tr,const uint8_t[], -Variable,-,u8g2_font_9x15_m_symbols,const uint8_t[], -Variable,-,u8g2_font_9x15_me,const uint8_t[], -Variable,-,u8g2_font_9x15_mf,const uint8_t[], -Variable,-,u8g2_font_9x15_mn,const uint8_t[], -Variable,-,u8g2_font_9x15_mr,const uint8_t[], -Variable,-,u8g2_font_9x15_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_9x15_t_symbols,const uint8_t[], -Variable,-,u8g2_font_9x15_te,const uint8_t[], -Variable,-,u8g2_font_9x15_tf,const uint8_t[], -Variable,-,u8g2_font_9x15_tn,const uint8_t[], -Variable,-,u8g2_font_9x15_tr,const uint8_t[], -Variable,-,u8g2_font_9x18B_mf,const uint8_t[], -Variable,-,u8g2_font_9x18B_mn,const uint8_t[], -Variable,-,u8g2_font_9x18B_mr,const uint8_t[], -Variable,-,u8g2_font_9x18B_tf,const uint8_t[], -Variable,-,u8g2_font_9x18B_tn,const uint8_t[], -Variable,-,u8g2_font_9x18B_tr,const uint8_t[], -Variable,-,u8g2_font_9x18_mf,const uint8_t[], -Variable,-,u8g2_font_9x18_mn,const uint8_t[], -Variable,-,u8g2_font_9x18_mr,const uint8_t[], -Variable,-,u8g2_font_9x18_tf,const uint8_t[], -Variable,-,u8g2_font_9x18_tn,const uint8_t[], -Variable,-,u8g2_font_9x18_tr,const uint8_t[], -Variable,-,u8g2_font_BBSesque_te,const uint8_t[], -Variable,-,u8g2_font_BBSesque_tf,const uint8_t[], -Variable,-,u8g2_font_BBSesque_tr,const uint8_t[], -Variable,-,u8g2_font_BitTypeWriter_te,const uint8_t[], -Variable,-,u8g2_font_BitTypeWriter_tr,const uint8_t[], -Variable,-,u8g2_font_Born2bSportySlab_t_all,const uint8_t[], -Variable,-,u8g2_font_Born2bSportySlab_te,const uint8_t[], -Variable,-,u8g2_font_Born2bSportySlab_tf,const uint8_t[], -Variable,-,u8g2_font_Born2bSportySlab_tr,const uint8_t[], -Variable,-,u8g2_font_Born2bSportyV2_te,const uint8_t[], -Variable,-,u8g2_font_Born2bSportyV2_tf,const uint8_t[], -Variable,-,u8g2_font_Born2bSportyV2_tr,const uint8_t[], -Variable,-,u8g2_font_CursivePixel_tr,const uint8_t[], -Variable,-,u8g2_font_DigitalDiscoThin_te,const uint8_t[], -Variable,-,u8g2_font_DigitalDiscoThin_tf,const uint8_t[], -Variable,-,u8g2_font_DigitalDiscoThin_tn,const uint8_t[], -Variable,-,u8g2_font_DigitalDiscoThin_tr,const uint8_t[], -Variable,-,u8g2_font_DigitalDiscoThin_tu,const uint8_t[], -Variable,-,u8g2_font_DigitalDisco_te,const uint8_t[], -Variable,-,u8g2_font_DigitalDisco_tf,const uint8_t[], -Variable,-,u8g2_font_DigitalDisco_tn,const uint8_t[], -Variable,-,u8g2_font_DigitalDisco_tr,const uint8_t[], -Variable,-,u8g2_font_DigitalDisco_tu,const uint8_t[], -Variable,-,u8g2_font_Engrish_tf,const uint8_t[], -Variable,-,u8g2_font_Engrish_tr,const uint8_t[], -Variable,-,u8g2_font_Georgia7px_te,const uint8_t[], -Variable,-,u8g2_font_Georgia7px_tf,const uint8_t[], -Variable,-,u8g2_font_Georgia7px_tr,const uint8_t[], -Variable,-,u8g2_font_HelvetiPixelOutline_te,const uint8_t[], -Variable,-,u8g2_font_HelvetiPixelOutline_tr,const uint8_t[], -Variable,-,u8g2_font_HelvetiPixel_tr,const uint8_t[], -Variable,-,u8g2_font_IPAandRUSLCD_te,const uint8_t[], -Variable,-,u8g2_font_IPAandRUSLCD_tf,const uint8_t[], -Variable,-,u8g2_font_IPAandRUSLCD_tr,const uint8_t[], -Variable,-,u8g2_font_ImpactBits_tr,const uint8_t[], -Variable,-,u8g2_font_Pixellari_te,const uint8_t[], -Variable,-,u8g2_font_Pixellari_tf,const uint8_t[], -Variable,-,u8g2_font_Pixellari_tn,const uint8_t[], -Variable,-,u8g2_font_Pixellari_tr,const uint8_t[], -Variable,-,u8g2_font_Pixellari_tu,const uint8_t[], -Variable,-,u8g2_font_TimesNewPixel_tr,const uint8_t[], -Variable,-,u8g2_font_Untitled16PixelSansSerifBitmap_tr,const uint8_t[], -Variable,-,u8g2_font_VCR_OSD_mf,const uint8_t[], -Variable,-,u8g2_font_VCR_OSD_mn,const uint8_t[], -Variable,-,u8g2_font_VCR_OSD_mr,const uint8_t[], -Variable,-,u8g2_font_VCR_OSD_mu,const uint8_t[], -Variable,-,u8g2_font_VCR_OSD_tf,const uint8_t[], -Variable,-,u8g2_font_VCR_OSD_tn,const uint8_t[], -Variable,-,u8g2_font_VCR_OSD_tr,const uint8_t[], -Variable,-,u8g2_font_VCR_OSD_tu,const uint8_t[], -Variable,-,u8g2_font_Wizzard_tr,const uint8_t[], -Variable,-,u8g2_font_adventurer_t_all,const uint8_t[], -Variable,-,u8g2_font_adventurer_tf,const uint8_t[], -Variable,-,u8g2_font_adventurer_tr,const uint8_t[], -Variable,-,u8g2_font_amstrad_cpc_extended_8f,const uint8_t[], -Variable,-,u8g2_font_amstrad_cpc_extended_8n,const uint8_t[], -Variable,-,u8g2_font_amstrad_cpc_extended_8r,const uint8_t[], -Variable,-,u8g2_font_amstrad_cpc_extended_8u,const uint8_t[], -Variable,-,u8g2_font_artossans8_8n,const uint8_t[], -Variable,-,u8g2_font_artossans8_8r,const uint8_t[], -Variable,-,u8g2_font_artossans8_8u,const uint8_t[], -Variable,-,u8g2_font_artosserif8_8n,const uint8_t[], -Variable,-,u8g2_font_artosserif8_8r,const uint8_t[], -Variable,-,u8g2_font_artosserif8_8u,const uint8_t[], -Variable,-,u8g2_font_astragal_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_astragal_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_astragal_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_b10_b_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_b10_b_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_b10_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_b10_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_b12_b_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_b12_b_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_b12_b_t_japanese3,const uint8_t[], -Variable,-,u8g2_font_b12_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_b12_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_b12_t_japanese3,const uint8_t[], -Variable,-,u8g2_font_b16_b_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_b16_b_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_b16_b_t_japanese3,const uint8_t[], -Variable,-,u8g2_font_b16_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_b16_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_b16_t_japanese3,const uint8_t[], -Variable,-,u8g2_font_baby_tf,const uint8_t[], -Variable,-,u8g2_font_baby_tn,const uint8_t[], -Variable,-,u8g2_font_baby_tr,const uint8_t[], -Variable,-,u8g2_font_balthasar_regular_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_balthasar_regular_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_balthasar_regular_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_balthasar_titling_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_balthasar_titling_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_balthasar_titling_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_battery19_tn,const uint8_t[], -Variable,-,u8g2_font_bauhaus2015_tn,const uint8_t[], -Variable,-,u8g2_font_bauhaus2015_tr,const uint8_t[], -Variable,-,u8g2_font_beanstalk_mel_tn,const uint8_t[], -Variable,-,u8g2_font_beanstalk_mel_tr,const uint8_t[], -Variable,-,u8g2_font_bitcasual_t_all,const uint8_t[], -Variable,-,u8g2_font_bitcasual_tf,const uint8_t[], -Variable,-,u8g2_font_bitcasual_tn,const uint8_t[], -Variable,-,u8g2_font_bitcasual_tr,const uint8_t[], -Variable,-,u8g2_font_bitcasual_tu,const uint8_t[], -Variable,-,u8g2_font_blipfest_07_tn,const uint8_t[], -Variable,-,u8g2_font_blipfest_07_tr,const uint8_t[], -Variable,-,u8g2_font_bracketedbabies_tr,const uint8_t[], -Variable,-,u8g2_font_bubble_tn,const uint8_t[], -Variable,-,u8g2_font_bubble_tr,const uint8_t[], -Variable,-,u8g2_font_calibration_gothic_nbp_t_all,const uint8_t[], -Variable,-,u8g2_font_calibration_gothic_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_calibration_gothic_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_calibration_gothic_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_cardimon_pixel_tf,const uint8_t[], -Variable,-,u8g2_font_cardimon_pixel_tn,const uint8_t[], -Variable,-,u8g2_font_cardimon_pixel_tr,const uint8_t[], -Variable,-,u8g2_font_celibatemonk_tr,const uint8_t[], -Variable,-,u8g2_font_chikita_tf,const uint8_t[], -Variable,-,u8g2_font_chikita_tn,const uint8_t[], -Variable,-,u8g2_font_chikita_tr,const uint8_t[], -Variable,-,u8g2_font_chroma48medium8_8n,const uint8_t[], -Variable,-,u8g2_font_chroma48medium8_8r,const uint8_t[], -Variable,-,u8g2_font_chroma48medium8_8u,const uint8_t[], -Variable,-,u8g2_font_courB08_tf,const uint8_t[], -Variable,-,u8g2_font_courB08_tn,const uint8_t[], -Variable,-,u8g2_font_courB08_tr,const uint8_t[], -Variable,-,u8g2_font_courB10_tf,const uint8_t[], -Variable,-,u8g2_font_courB10_tn,const uint8_t[], -Variable,-,u8g2_font_courB10_tr,const uint8_t[], -Variable,-,u8g2_font_courB12_tf,const uint8_t[], -Variable,-,u8g2_font_courB12_tn,const uint8_t[], -Variable,-,u8g2_font_courB12_tr,const uint8_t[], -Variable,-,u8g2_font_courB14_tf,const uint8_t[], -Variable,-,u8g2_font_courB14_tn,const uint8_t[], -Variable,-,u8g2_font_courB14_tr,const uint8_t[], -Variable,-,u8g2_font_courB18_tf,const uint8_t[], -Variable,-,u8g2_font_courB18_tn,const uint8_t[], -Variable,-,u8g2_font_courB18_tr,const uint8_t[], -Variable,-,u8g2_font_courB24_tf,const uint8_t[], -Variable,-,u8g2_font_courB24_tn,const uint8_t[], -Variable,-,u8g2_font_courB24_tr,const uint8_t[], -Variable,-,u8g2_font_courR08_tf,const uint8_t[], -Variable,-,u8g2_font_courR08_tn,const uint8_t[], -Variable,-,u8g2_font_courR08_tr,const uint8_t[], -Variable,-,u8g2_font_courR10_tf,const uint8_t[], -Variable,-,u8g2_font_courR10_tn,const uint8_t[], -Variable,-,u8g2_font_courR10_tr,const uint8_t[], -Variable,-,u8g2_font_courR12_tf,const uint8_t[], -Variable,-,u8g2_font_courR12_tn,const uint8_t[], -Variable,-,u8g2_font_courR12_tr,const uint8_t[], -Variable,-,u8g2_font_courR14_tf,const uint8_t[], -Variable,-,u8g2_font_courR14_tn,const uint8_t[], -Variable,-,u8g2_font_courR14_tr,const uint8_t[], -Variable,-,u8g2_font_courR18_tf,const uint8_t[], -Variable,-,u8g2_font_courR18_tn,const uint8_t[], -Variable,-,u8g2_font_courR18_tr,const uint8_t[], -Variable,-,u8g2_font_courR24_tf,const uint8_t[], -Variable,-,u8g2_font_courR24_tn,const uint8_t[], -Variable,-,u8g2_font_courR24_tr,const uint8_t[], -Variable,-,u8g2_font_crox1c_mf,const uint8_t[], -Variable,-,u8g2_font_crox1c_mn,const uint8_t[], -Variable,-,u8g2_font_crox1c_mr,const uint8_t[], -Variable,-,u8g2_font_crox1c_tf,const uint8_t[], -Variable,-,u8g2_font_crox1c_tn,const uint8_t[], -Variable,-,u8g2_font_crox1c_tr,const uint8_t[], -Variable,-,u8g2_font_crox1cb_mf,const uint8_t[], -Variable,-,u8g2_font_crox1cb_mn,const uint8_t[], -Variable,-,u8g2_font_crox1cb_mr,const uint8_t[], -Variable,-,u8g2_font_crox1cb_tf,const uint8_t[], -Variable,-,u8g2_font_crox1cb_tn,const uint8_t[], -Variable,-,u8g2_font_crox1cb_tr,const uint8_t[], -Variable,-,u8g2_font_crox1h_tf,const uint8_t[], -Variable,-,u8g2_font_crox1h_tn,const uint8_t[], -Variable,-,u8g2_font_crox1h_tr,const uint8_t[], -Variable,-,u8g2_font_crox1hb_tf,const uint8_t[], -Variable,-,u8g2_font_crox1hb_tn,const uint8_t[], -Variable,-,u8g2_font_crox1hb_tr,const uint8_t[], -Variable,-,u8g2_font_crox1t_tf,const uint8_t[], -Variable,-,u8g2_font_crox1t_tn,const uint8_t[], -Variable,-,u8g2_font_crox1t_tr,const uint8_t[], -Variable,-,u8g2_font_crox1tb_tf,const uint8_t[], -Variable,-,u8g2_font_crox1tb_tn,const uint8_t[], -Variable,-,u8g2_font_crox1tb_tr,const uint8_t[], -Variable,-,u8g2_font_crox2c_mf,const uint8_t[], -Variable,-,u8g2_font_crox2c_mn,const uint8_t[], -Variable,-,u8g2_font_crox2c_mr,const uint8_t[], -Variable,-,u8g2_font_crox2c_tf,const uint8_t[], -Variable,-,u8g2_font_crox2c_tn,const uint8_t[], -Variable,-,u8g2_font_crox2c_tr,const uint8_t[], -Variable,-,u8g2_font_crox2cb_mf,const uint8_t[], -Variable,-,u8g2_font_crox2cb_mn,const uint8_t[], -Variable,-,u8g2_font_crox2cb_mr,const uint8_t[], -Variable,-,u8g2_font_crox2cb_tf,const uint8_t[], -Variable,-,u8g2_font_crox2cb_tn,const uint8_t[], -Variable,-,u8g2_font_crox2cb_tr,const uint8_t[], -Variable,-,u8g2_font_crox2h_tf,const uint8_t[], -Variable,-,u8g2_font_crox2h_tn,const uint8_t[], -Variable,-,u8g2_font_crox2h_tr,const uint8_t[], -Variable,-,u8g2_font_crox2hb_tf,const uint8_t[], -Variable,-,u8g2_font_crox2hb_tn,const uint8_t[], -Variable,-,u8g2_font_crox2hb_tr,const uint8_t[], -Variable,-,u8g2_font_crox2t_tf,const uint8_t[], -Variable,-,u8g2_font_crox2t_tn,const uint8_t[], -Variable,-,u8g2_font_crox2t_tr,const uint8_t[], -Variable,-,u8g2_font_crox2tb_tf,const uint8_t[], -Variable,-,u8g2_font_crox2tb_tn,const uint8_t[], -Variable,-,u8g2_font_crox2tb_tr,const uint8_t[], -Variable,-,u8g2_font_crox3c_mf,const uint8_t[], -Variable,-,u8g2_font_crox3c_mn,const uint8_t[], -Variable,-,u8g2_font_crox3c_mr,const uint8_t[], -Variable,-,u8g2_font_crox3c_tf,const uint8_t[], -Variable,-,u8g2_font_crox3c_tn,const uint8_t[], -Variable,-,u8g2_font_crox3c_tr,const uint8_t[], -Variable,-,u8g2_font_crox3cb_mf,const uint8_t[], -Variable,-,u8g2_font_crox3cb_mn,const uint8_t[], -Variable,-,u8g2_font_crox3cb_mr,const uint8_t[], -Variable,-,u8g2_font_crox3cb_tf,const uint8_t[], -Variable,-,u8g2_font_crox3cb_tn,const uint8_t[], -Variable,-,u8g2_font_crox3cb_tr,const uint8_t[], -Variable,-,u8g2_font_crox3h_tf,const uint8_t[], -Variable,-,u8g2_font_crox3h_tn,const uint8_t[], -Variable,-,u8g2_font_crox3h_tr,const uint8_t[], -Variable,-,u8g2_font_crox3hb_tf,const uint8_t[], -Variable,-,u8g2_font_crox3hb_tn,const uint8_t[], -Variable,-,u8g2_font_crox3hb_tr,const uint8_t[], -Variable,-,u8g2_font_crox3t_tf,const uint8_t[], -Variable,-,u8g2_font_crox3t_tn,const uint8_t[], -Variable,-,u8g2_font_crox3t_tr,const uint8_t[], -Variable,-,u8g2_font_crox3tb_tf,const uint8_t[], -Variable,-,u8g2_font_crox3tb_tn,const uint8_t[], -Variable,-,u8g2_font_crox3tb_tr,const uint8_t[], -Variable,-,u8g2_font_crox4h_tf,const uint8_t[], -Variable,-,u8g2_font_crox4h_tn,const uint8_t[], -Variable,-,u8g2_font_crox4h_tr,const uint8_t[], -Variable,-,u8g2_font_crox4hb_tf,const uint8_t[], -Variable,-,u8g2_font_crox4hb_tn,const uint8_t[], -Variable,-,u8g2_font_crox4hb_tr,const uint8_t[], -Variable,-,u8g2_font_crox4t_tf,const uint8_t[], -Variable,-,u8g2_font_crox4t_tn,const uint8_t[], -Variable,-,u8g2_font_crox4t_tr,const uint8_t[], -Variable,-,u8g2_font_crox4tb_tf,const uint8_t[], -Variable,-,u8g2_font_crox4tb_tn,const uint8_t[], -Variable,-,u8g2_font_crox4tb_tr,const uint8_t[], -Variable,-,u8g2_font_crox5h_tf,const uint8_t[], -Variable,-,u8g2_font_crox5h_tn,const uint8_t[], -Variable,-,u8g2_font_crox5h_tr,const uint8_t[], -Variable,-,u8g2_font_crox5hb_tf,const uint8_t[], -Variable,-,u8g2_font_crox5hb_tn,const uint8_t[], -Variable,-,u8g2_font_crox5hb_tr,const uint8_t[], -Variable,-,u8g2_font_crox5t_tf,const uint8_t[], -Variable,-,u8g2_font_crox5t_tn,const uint8_t[], -Variable,-,u8g2_font_crox5t_tr,const uint8_t[], -Variable,-,u8g2_font_crox5tb_tf,const uint8_t[], -Variable,-,u8g2_font_crox5tb_tn,const uint8_t[], -Variable,-,u8g2_font_crox5tb_tr,const uint8_t[], -Variable,-,u8g2_font_cu12_h_symbols,const uint8_t[], -Variable,-,u8g2_font_cu12_he,const uint8_t[], -Variable,-,u8g2_font_cu12_hf,const uint8_t[], -Variable,-,u8g2_font_cu12_hn,const uint8_t[], -Variable,-,u8g2_font_cu12_hr,const uint8_t[], -Variable,-,u8g2_font_cu12_me,const uint8_t[], -Variable,-,u8g2_font_cu12_mf,const uint8_t[], -Variable,-,u8g2_font_cu12_mn,const uint8_t[], -Variable,-,u8g2_font_cu12_mr,const uint8_t[], -Variable,-,u8g2_font_cu12_t_arabic,const uint8_t[], -Variable,-,u8g2_font_cu12_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_cu12_t_greek,const uint8_t[], -Variable,-,u8g2_font_cu12_t_hebrew,const uint8_t[], -Variable,-,u8g2_font_cu12_t_symbols,const uint8_t[], -Variable,-,u8g2_font_cu12_t_tibetan,const uint8_t[], -Variable,-,u8g2_font_cu12_te,const uint8_t[], -Variable,-,u8g2_font_cu12_tf,const uint8_t[], -Variable,-,u8g2_font_cu12_tn,const uint8_t[], -Variable,-,u8g2_font_cu12_tr,const uint8_t[], -Variable,-,u8g2_font_cube_mel_tn,const uint8_t[], -Variable,-,u8g2_font_cube_mel_tr,const uint8_t[], -Variable,-,u8g2_font_cupcakemetoyourleader_tn,const uint8_t[], -Variable,-,u8g2_font_cupcakemetoyourleader_tr,const uint8_t[], -Variable,-,u8g2_font_cupcakemetoyourleader_tu,const uint8_t[], -Variable,-,u8g2_font_cursor_tf,const uint8_t[], -Variable,-,u8g2_font_cursor_tr,const uint8_t[], -Variable,-,u8g2_font_diodesemimono_tr,const uint8_t[], -Variable,-,u8g2_font_disrespectfulteenager_tu,const uint8_t[], -Variable,-,u8g2_font_emoticons21_tr,const uint8_t[], -Variable,-,u8g2_font_etl14thai_t,const uint8_t[], -Variable,-,u8g2_font_etl16thai_t,const uint8_t[], -Variable,-,u8g2_font_etl24thai_t,const uint8_t[], -Variable,-,u8g2_font_f10_b_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_f10_b_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_f10_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_f10_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_f12_b_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_f12_b_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_f12_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_f12_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_f16_b_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_f16_b_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_f16_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_f16_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_fancypixels_tf,const uint8_t[], -Variable,-,u8g2_font_fancypixels_tr,const uint8_t[], -Variable,-,u8g2_font_fewture_tf,const uint8_t[], -Variable,-,u8g2_font_fewture_tn,const uint8_t[], -Variable,-,u8g2_font_fewture_tr,const uint8_t[], -Variable,-,u8g2_font_finderskeepers_tf,const uint8_t[], -Variable,-,u8g2_font_finderskeepers_tn,const uint8_t[], -Variable,-,u8g2_font_finderskeepers_tr,const uint8_t[], -Variable,-,u8g2_font_freedoomr10_mu,const uint8_t[], -Variable,-,u8g2_font_freedoomr10_tu,const uint8_t[], -Variable,-,u8g2_font_freedoomr25_mn,const uint8_t[], -Variable,-,u8g2_font_freedoomr25_tn,const uint8_t[], -Variable,-,u8g2_font_frikativ_t_all,const uint8_t[], -Variable,-,u8g2_font_frikativ_tf,const uint8_t[], -Variable,-,u8g2_font_frikativ_tr,const uint8_t[], -Variable,-,u8g2_font_fub11_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fub11_tf,const uint8_t[], -Variable,-,u8g2_font_fub11_tn,const uint8_t[], -Variable,-,u8g2_font_fub11_tr,const uint8_t[], -Variable,-,u8g2_font_fub14_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fub14_tf,const uint8_t[], -Variable,-,u8g2_font_fub14_tn,const uint8_t[], -Variable,-,u8g2_font_fub14_tr,const uint8_t[], -Variable,-,u8g2_font_fub17_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fub17_tf,const uint8_t[], -Variable,-,u8g2_font_fub17_tn,const uint8_t[], -Variable,-,u8g2_font_fub17_tr,const uint8_t[], -Variable,-,u8g2_font_fub20_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fub20_tf,const uint8_t[], -Variable,-,u8g2_font_fub20_tn,const uint8_t[], -Variable,-,u8g2_font_fub20_tr,const uint8_t[], -Variable,-,u8g2_font_fub25_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fub25_tf,const uint8_t[], -Variable,-,u8g2_font_fub25_tn,const uint8_t[], -Variable,-,u8g2_font_fub25_tr,const uint8_t[], -Variable,-,u8g2_font_fub30_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fub30_tf,const uint8_t[], -Variable,-,u8g2_font_fub30_tn,const uint8_t[], -Variable,-,u8g2_font_fub30_tr,const uint8_t[], -Variable,-,u8g2_font_fub35_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fub35_tf,const uint8_t[], -Variable,-,u8g2_font_fub35_tn,const uint8_t[], -Variable,-,u8g2_font_fub35_tr,const uint8_t[], -Variable,-,u8g2_font_fub42_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fub42_tf,const uint8_t[], -Variable,-,u8g2_font_fub42_tn,const uint8_t[], -Variable,-,u8g2_font_fub42_tr,const uint8_t[], -Variable,-,u8g2_font_fub49_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fub49_tn,const uint8_t[], -Variable,-,u8g2_font_fur11_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fur11_tf,const uint8_t[], -Variable,-,u8g2_font_fur11_tn,const uint8_t[], -Variable,-,u8g2_font_fur11_tr,const uint8_t[], -Variable,-,u8g2_font_fur14_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fur14_tf,const uint8_t[], -Variable,-,u8g2_font_fur14_tn,const uint8_t[], -Variable,-,u8g2_font_fur14_tr,const uint8_t[], -Variable,-,u8g2_font_fur17_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fur17_tf,const uint8_t[], -Variable,-,u8g2_font_fur17_tn,const uint8_t[], -Variable,-,u8g2_font_fur17_tr,const uint8_t[], -Variable,-,u8g2_font_fur20_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fur20_tf,const uint8_t[], -Variable,-,u8g2_font_fur20_tn,const uint8_t[], -Variable,-,u8g2_font_fur20_tr,const uint8_t[], -Variable,-,u8g2_font_fur25_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fur25_tf,const uint8_t[], -Variable,-,u8g2_font_fur25_tn,const uint8_t[], -Variable,-,u8g2_font_fur25_tr,const uint8_t[], -Variable,-,u8g2_font_fur30_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fur30_tf,const uint8_t[], -Variable,-,u8g2_font_fur30_tn,const uint8_t[], -Variable,-,u8g2_font_fur30_tr,const uint8_t[], -Variable,-,u8g2_font_fur35_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fur35_tf,const uint8_t[], -Variable,-,u8g2_font_fur35_tn,const uint8_t[], -Variable,-,u8g2_font_fur35_tr,const uint8_t[], -Variable,-,u8g2_font_fur42_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fur42_tf,const uint8_t[], -Variable,-,u8g2_font_fur42_tn,const uint8_t[], -Variable,-,u8g2_font_fur42_tr,const uint8_t[], -Variable,-,u8g2_font_fur49_t_symbol,const uint8_t[], -Variable,-,u8g2_font_fur49_tn,const uint8_t[], -Variable,-,u8g2_font_ganj_nameh_sans10_t_all,const uint8_t[], -Variable,-,u8g2_font_ganj_nameh_sans12_t_all,const uint8_t[], -Variable,-,u8g2_font_ganj_nameh_sans14_t_all,const uint8_t[], -Variable,-,u8g2_font_ganj_nameh_sans16_t_all,const uint8_t[], -Variable,-,u8g2_font_gb16st_t_1,const uint8_t[], -Variable,-,u8g2_font_gb16st_t_2,const uint8_t[], -Variable,-,u8g2_font_gb16st_t_3,const uint8_t[], -Variable,-,u8g2_font_gb24st_t_1,const uint8_t[], -Variable,-,u8g2_font_gb24st_t_2,const uint8_t[], -Variable,-,u8g2_font_gb24st_t_3,const uint8_t[], -Variable,-,u8g2_font_glasstown_nbp_t_all,const uint8_t[], -Variable,-,u8g2_font_glasstown_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_glasstown_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_glasstown_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_guildenstern_nbp_t_all,const uint8_t[], -Variable,-,u8g2_font_guildenstern_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_guildenstern_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_guildenstern_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_habsburgchancery_t_all,const uint8_t[], -Variable,-,u8g2_font_habsburgchancery_tf,const uint8_t[], -Variable,-,u8g2_font_habsburgchancery_tn,const uint8_t[], -Variable,-,u8g2_font_habsburgchancery_tr,const uint8_t[], -Variable,-,u8g2_font_halftone_tf,const uint8_t[], -Variable,-,u8g2_font_halftone_tn,const uint8_t[], -Variable,-,u8g2_font_halftone_tr,const uint8_t[], -Variable,-,u8g2_font_haxrcorp4089_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_haxrcorp4089_tn,const uint8_t[], -Variable,-,u8g2_font_haxrcorp4089_tr,const uint8_t[], -Variable,-,u8g2_font_heavybottom_tr,const uint8_t[], -Variable,-,u8g2_font_helvB08_te,const uint8_t[], -Variable,-,u8g2_font_helvB08_tf,const uint8_t[], -Variable,-,u8g2_font_helvB08_tn,const uint8_t[], -Variable,-,u8g2_font_helvB08_tr,const uint8_t[], -Variable,-,u8g2_font_helvB10_te,const uint8_t[], -Variable,-,u8g2_font_helvB10_tf,const uint8_t[], -Variable,-,u8g2_font_helvB10_tn,const uint8_t[], -Variable,-,u8g2_font_helvB10_tr,const uint8_t[], -Variable,-,u8g2_font_helvB12_te,const uint8_t[], -Variable,-,u8g2_font_helvB12_tf,const uint8_t[], -Variable,-,u8g2_font_helvB12_tn,const uint8_t[], -Variable,-,u8g2_font_helvB12_tr,const uint8_t[], -Variable,-,u8g2_font_helvB14_te,const uint8_t[], -Variable,-,u8g2_font_helvB14_tf,const uint8_t[], -Variable,-,u8g2_font_helvB14_tn,const uint8_t[], -Variable,-,u8g2_font_helvB14_tr,const uint8_t[], -Variable,-,u8g2_font_helvB18_te,const uint8_t[], -Variable,-,u8g2_font_helvB18_tf,const uint8_t[], -Variable,-,u8g2_font_helvB18_tn,const uint8_t[], -Variable,-,u8g2_font_helvB18_tr,const uint8_t[], -Variable,-,u8g2_font_helvB24_te,const uint8_t[], -Variable,-,u8g2_font_helvB24_tf,const uint8_t[], -Variable,-,u8g2_font_helvB24_tn,const uint8_t[], -Variable,-,u8g2_font_helvB24_tr,const uint8_t[], -Variable,-,u8g2_font_helvR08_te,const uint8_t[], -Variable,-,u8g2_font_helvR08_tf,const uint8_t[], -Variable,-,u8g2_font_helvR08_tn,const uint8_t[], -Variable,-,u8g2_font_helvR08_tr,const uint8_t[], -Variable,-,u8g2_font_helvR10_te,const uint8_t[], -Variable,-,u8g2_font_helvR10_tf,const uint8_t[], -Variable,-,u8g2_font_helvR10_tn,const uint8_t[], -Variable,-,u8g2_font_helvR10_tr,const uint8_t[], -Variable,-,u8g2_font_helvR12_te,const uint8_t[], -Variable,-,u8g2_font_helvR12_tf,const uint8_t[], -Variable,-,u8g2_font_helvR12_tn,const uint8_t[], -Variable,-,u8g2_font_helvR12_tr,const uint8_t[], -Variable,-,u8g2_font_helvR14_te,const uint8_t[], -Variable,-,u8g2_font_helvR14_tf,const uint8_t[], -Variable,-,u8g2_font_helvR14_tn,const uint8_t[], -Variable,-,u8g2_font_helvR14_tr,const uint8_t[], -Variable,-,u8g2_font_helvR18_te,const uint8_t[], -Variable,-,u8g2_font_helvR18_tf,const uint8_t[], -Variable,-,u8g2_font_helvR18_tn,const uint8_t[], -Variable,-,u8g2_font_helvR18_tr,const uint8_t[], -Variable,-,u8g2_font_helvR24_te,const uint8_t[], -Variable,-,u8g2_font_helvR24_tf,const uint8_t[], -Variable,-,u8g2_font_helvR24_tn,const uint8_t[], -Variable,-,u8g2_font_helvR24_tr,const uint8_t[], -Variable,-,u8g2_font_iconquadpix_m_all,const uint8_t[], -Variable,-,u8g2_font_inb16_mf,const uint8_t[], -Variable,-,u8g2_font_inb16_mn,const uint8_t[], -Variable,-,u8g2_font_inb16_mr,const uint8_t[], -Variable,-,u8g2_font_inb19_mf,const uint8_t[], -Variable,-,u8g2_font_inb19_mn,const uint8_t[], -Variable,-,u8g2_font_inb19_mr,const uint8_t[], -Variable,-,u8g2_font_inb21_mf,const uint8_t[], -Variable,-,u8g2_font_inb21_mn,const uint8_t[], -Variable,-,u8g2_font_inb21_mr,const uint8_t[], -Variable,-,u8g2_font_inb24_mf,const uint8_t[], -Variable,-,u8g2_font_inb24_mn,const uint8_t[], -Variable,-,u8g2_font_inb24_mr,const uint8_t[], -Variable,-,u8g2_font_inb27_mf,const uint8_t[], -Variable,-,u8g2_font_inb27_mn,const uint8_t[], -Variable,-,u8g2_font_inb27_mr,const uint8_t[], -Variable,-,u8g2_font_inb30_mf,const uint8_t[], -Variable,-,u8g2_font_inb30_mn,const uint8_t[], -Variable,-,u8g2_font_inb30_mr,const uint8_t[], -Variable,-,u8g2_font_inb33_mf,const uint8_t[], -Variable,-,u8g2_font_inb33_mn,const uint8_t[], -Variable,-,u8g2_font_inb33_mr,const uint8_t[], -Variable,-,u8g2_font_inb38_mf,const uint8_t[], -Variable,-,u8g2_font_inb38_mn,const uint8_t[], -Variable,-,u8g2_font_inb38_mr,const uint8_t[], -Variable,-,u8g2_font_inb42_mf,const uint8_t[], -Variable,-,u8g2_font_inb42_mn,const uint8_t[], -Variable,-,u8g2_font_inb42_mr,const uint8_t[], -Variable,-,u8g2_font_inb46_mf,const uint8_t[], -Variable,-,u8g2_font_inb46_mn,const uint8_t[], -Variable,-,u8g2_font_inb46_mr,const uint8_t[], -Variable,-,u8g2_font_inb49_mf,const uint8_t[], -Variable,-,u8g2_font_inb49_mn,const uint8_t[], -Variable,-,u8g2_font_inb49_mr,const uint8_t[], -Variable,-,u8g2_font_inb53_mf,const uint8_t[], -Variable,-,u8g2_font_inb53_mn,const uint8_t[], -Variable,-,u8g2_font_inb53_mr,const uint8_t[], -Variable,-,u8g2_font_inb57_mn,const uint8_t[], -Variable,-,u8g2_font_inb63_mn,const uint8_t[], -Variable,-,u8g2_font_inr16_mf,const uint8_t[], -Variable,-,u8g2_font_inr16_mn,const uint8_t[], -Variable,-,u8g2_font_inr16_mr,const uint8_t[], -Variable,-,u8g2_font_inr19_mf,const uint8_t[], -Variable,-,u8g2_font_inr19_mn,const uint8_t[], -Variable,-,u8g2_font_inr19_mr,const uint8_t[], -Variable,-,u8g2_font_inr21_mf,const uint8_t[], -Variable,-,u8g2_font_inr21_mn,const uint8_t[], -Variable,-,u8g2_font_inr21_mr,const uint8_t[], -Variable,-,u8g2_font_inr24_mf,const uint8_t[], -Variable,-,u8g2_font_inr24_mn,const uint8_t[], -Variable,-,u8g2_font_inr24_mr,const uint8_t[], -Variable,-,u8g2_font_inr24_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_inr27_mf,const uint8_t[], -Variable,-,u8g2_font_inr27_mn,const uint8_t[], -Variable,-,u8g2_font_inr27_mr,const uint8_t[], -Variable,-,u8g2_font_inr27_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_inr30_mf,const uint8_t[], -Variable,-,u8g2_font_inr30_mn,const uint8_t[], -Variable,-,u8g2_font_inr30_mr,const uint8_t[], -Variable,-,u8g2_font_inr30_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_inr33_mf,const uint8_t[], -Variable,-,u8g2_font_inr33_mn,const uint8_t[], -Variable,-,u8g2_font_inr33_mr,const uint8_t[], -Variable,-,u8g2_font_inr33_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_inr38_mf,const uint8_t[], -Variable,-,u8g2_font_inr38_mn,const uint8_t[], -Variable,-,u8g2_font_inr38_mr,const uint8_t[], -Variable,-,u8g2_font_inr38_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_inr42_mf,const uint8_t[], -Variable,-,u8g2_font_inr42_mn,const uint8_t[], -Variable,-,u8g2_font_inr42_mr,const uint8_t[], -Variable,-,u8g2_font_inr42_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_inr46_mf,const uint8_t[], -Variable,-,u8g2_font_inr46_mn,const uint8_t[], -Variable,-,u8g2_font_inr46_mr,const uint8_t[], -Variable,-,u8g2_font_inr46_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_inr49_mf,const uint8_t[], -Variable,-,u8g2_font_inr49_mn,const uint8_t[], -Variable,-,u8g2_font_inr49_mr,const uint8_t[], -Variable,-,u8g2_font_inr49_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_inr53_mf,const uint8_t[], -Variable,-,u8g2_font_inr53_mn,const uint8_t[], -Variable,-,u8g2_font_inr53_mr,const uint8_t[], -Variable,-,u8g2_font_inr53_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_inr57_mn,const uint8_t[], -Variable,-,u8g2_font_inr62_mn,const uint8_t[], -Variable,-,u8g2_font_iranian_sans_10_t_all,const uint8_t[], -Variable,-,u8g2_font_iranian_sans_12_t_all,const uint8_t[], -Variable,-,u8g2_font_iranian_sans_14_t_all,const uint8_t[], -Variable,-,u8g2_font_iranian_sans_16_t_all,const uint8_t[], -Variable,-,u8g2_font_iranian_sans_8_t_all,const uint8_t[], -Variable,-,u8g2_font_jinxedwizards_tr,const uint8_t[], -Variable,-,u8g2_font_koleeko_tf,const uint8_t[], -Variable,-,u8g2_font_koleeko_tn,const uint8_t[], -Variable,-,u8g2_font_koleeko_tr,const uint8_t[], -Variable,-,u8g2_font_koleeko_tu,const uint8_t[], -Variable,-,u8g2_font_lastapprenticebold_tr,const uint8_t[], -Variable,-,u8g2_font_lastapprenticethin_tr,const uint8_t[], -Variable,-,u8g2_font_lastpriestess_tr,const uint8_t[], -Variable,-,u8g2_font_lastpriestess_tu,const uint8_t[], -Variable,-,u8g2_font_logisoso16_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso16_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso16_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso18_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso18_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso18_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso20_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso20_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso20_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso22_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso22_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso22_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso24_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso24_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso24_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso26_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso26_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso26_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso28_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso28_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso28_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso30_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso30_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso30_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso32_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso32_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso32_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso34_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso34_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso34_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso38_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso38_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso38_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso42_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso42_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso42_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso46_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso46_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso46_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso50_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso50_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso50_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso54_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso54_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso54_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso58_tf,const uint8_t[], -Variable,-,u8g2_font_logisoso58_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso58_tr,const uint8_t[], -Variable,-,u8g2_font_logisoso62_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso78_tn,const uint8_t[], -Variable,-,u8g2_font_logisoso92_tn,const uint8_t[], -Variable,-,u8g2_font_luBIS08_te,const uint8_t[], -Variable,-,u8g2_font_luBIS08_tf,const uint8_t[], -Variable,-,u8g2_font_luBIS08_tn,const uint8_t[], -Variable,-,u8g2_font_luBIS08_tr,const uint8_t[], -Variable,-,u8g2_font_luBIS10_te,const uint8_t[], -Variable,-,u8g2_font_luBIS10_tf,const uint8_t[], -Variable,-,u8g2_font_luBIS10_tn,const uint8_t[], -Variable,-,u8g2_font_luBIS10_tr,const uint8_t[], -Variable,-,u8g2_font_luBIS12_te,const uint8_t[], -Variable,-,u8g2_font_luBIS12_tf,const uint8_t[], -Variable,-,u8g2_font_luBIS12_tn,const uint8_t[], -Variable,-,u8g2_font_luBIS12_tr,const uint8_t[], -Variable,-,u8g2_font_luBIS14_te,const uint8_t[], -Variable,-,u8g2_font_luBIS14_tf,const uint8_t[], -Variable,-,u8g2_font_luBIS14_tn,const uint8_t[], -Variable,-,u8g2_font_luBIS14_tr,const uint8_t[], -Variable,-,u8g2_font_luBIS18_te,const uint8_t[], -Variable,-,u8g2_font_luBIS18_tf,const uint8_t[], -Variable,-,u8g2_font_luBIS18_tn,const uint8_t[], -Variable,-,u8g2_font_luBIS18_tr,const uint8_t[], -Variable,-,u8g2_font_luBIS19_te,const uint8_t[], -Variable,-,u8g2_font_luBIS19_tf,const uint8_t[], -Variable,-,u8g2_font_luBIS19_tn,const uint8_t[], -Variable,-,u8g2_font_luBIS19_tr,const uint8_t[], -Variable,-,u8g2_font_luBIS24_te,const uint8_t[], -Variable,-,u8g2_font_luBIS24_tf,const uint8_t[], -Variable,-,u8g2_font_luBIS24_tn,const uint8_t[], -Variable,-,u8g2_font_luBIS24_tr,const uint8_t[], -Variable,-,u8g2_font_luBS08_te,const uint8_t[], -Variable,-,u8g2_font_luBS08_tf,const uint8_t[], -Variable,-,u8g2_font_luBS08_tn,const uint8_t[], -Variable,-,u8g2_font_luBS08_tr,const uint8_t[], -Variable,-,u8g2_font_luBS10_te,const uint8_t[], -Variable,-,u8g2_font_luBS10_tf,const uint8_t[], -Variable,-,u8g2_font_luBS10_tn,const uint8_t[], -Variable,-,u8g2_font_luBS10_tr,const uint8_t[], -Variable,-,u8g2_font_luBS12_te,const uint8_t[], -Variable,-,u8g2_font_luBS12_tf,const uint8_t[], -Variable,-,u8g2_font_luBS12_tn,const uint8_t[], -Variable,-,u8g2_font_luBS12_tr,const uint8_t[], -Variable,-,u8g2_font_luBS14_te,const uint8_t[], -Variable,-,u8g2_font_luBS14_tf,const uint8_t[], -Variable,-,u8g2_font_luBS14_tn,const uint8_t[], -Variable,-,u8g2_font_luBS14_tr,const uint8_t[], -Variable,-,u8g2_font_luBS18_te,const uint8_t[], -Variable,-,u8g2_font_luBS18_tf,const uint8_t[], -Variable,-,u8g2_font_luBS18_tn,const uint8_t[], -Variable,-,u8g2_font_luBS18_tr,const uint8_t[], -Variable,-,u8g2_font_luBS19_te,const uint8_t[], -Variable,-,u8g2_font_luBS19_tf,const uint8_t[], -Variable,-,u8g2_font_luBS19_tn,const uint8_t[], -Variable,-,u8g2_font_luBS19_tr,const uint8_t[], -Variable,-,u8g2_font_luBS24_te,const uint8_t[], -Variable,-,u8g2_font_luBS24_tf,const uint8_t[], -Variable,-,u8g2_font_luBS24_tn,const uint8_t[], -Variable,-,u8g2_font_luBS24_tr,const uint8_t[], -Variable,-,u8g2_font_luIS08_te,const uint8_t[], -Variable,-,u8g2_font_luIS08_tf,const uint8_t[], -Variable,-,u8g2_font_luIS08_tn,const uint8_t[], -Variable,-,u8g2_font_luIS08_tr,const uint8_t[], -Variable,-,u8g2_font_luIS10_te,const uint8_t[], -Variable,-,u8g2_font_luIS10_tf,const uint8_t[], -Variable,-,u8g2_font_luIS10_tn,const uint8_t[], -Variable,-,u8g2_font_luIS10_tr,const uint8_t[], -Variable,-,u8g2_font_luIS12_te,const uint8_t[], -Variable,-,u8g2_font_luIS12_tf,const uint8_t[], -Variable,-,u8g2_font_luIS12_tn,const uint8_t[], -Variable,-,u8g2_font_luIS12_tr,const uint8_t[], -Variable,-,u8g2_font_luIS14_te,const uint8_t[], -Variable,-,u8g2_font_luIS14_tf,const uint8_t[], -Variable,-,u8g2_font_luIS14_tn,const uint8_t[], -Variable,-,u8g2_font_luIS14_tr,const uint8_t[], -Variable,-,u8g2_font_luIS18_te,const uint8_t[], -Variable,-,u8g2_font_luIS18_tf,const uint8_t[], -Variable,-,u8g2_font_luIS18_tn,const uint8_t[], -Variable,-,u8g2_font_luIS18_tr,const uint8_t[], -Variable,-,u8g2_font_luIS19_te,const uint8_t[], -Variable,-,u8g2_font_luIS19_tf,const uint8_t[], -Variable,-,u8g2_font_luIS19_tn,const uint8_t[], -Variable,-,u8g2_font_luIS19_tr,const uint8_t[], -Variable,-,u8g2_font_luIS24_te,const uint8_t[], -Variable,-,u8g2_font_luIS24_tf,const uint8_t[], -Variable,-,u8g2_font_luIS24_tn,const uint8_t[], -Variable,-,u8g2_font_luIS24_tr,const uint8_t[], -Variable,-,u8g2_font_luRS08_te,const uint8_t[], -Variable,-,u8g2_font_luRS08_tf,const uint8_t[], -Variable,-,u8g2_font_luRS08_tn,const uint8_t[], -Variable,-,u8g2_font_luRS08_tr,const uint8_t[], -Variable,-,u8g2_font_luRS10_te,const uint8_t[], -Variable,-,u8g2_font_luRS10_tf,const uint8_t[], -Variable,-,u8g2_font_luRS10_tn,const uint8_t[], -Variable,-,u8g2_font_luRS10_tr,const uint8_t[], -Variable,-,u8g2_font_luRS12_te,const uint8_t[], -Variable,-,u8g2_font_luRS12_tf,const uint8_t[], -Variable,-,u8g2_font_luRS12_tn,const uint8_t[], -Variable,-,u8g2_font_luRS12_tr,const uint8_t[], -Variable,-,u8g2_font_luRS14_te,const uint8_t[], -Variable,-,u8g2_font_luRS14_tf,const uint8_t[], -Variable,-,u8g2_font_luRS14_tn,const uint8_t[], -Variable,-,u8g2_font_luRS14_tr,const uint8_t[], -Variable,-,u8g2_font_luRS18_te,const uint8_t[], -Variable,-,u8g2_font_luRS18_tf,const uint8_t[], -Variable,-,u8g2_font_luRS18_tn,const uint8_t[], -Variable,-,u8g2_font_luRS18_tr,const uint8_t[], -Variable,-,u8g2_font_luRS19_te,const uint8_t[], -Variable,-,u8g2_font_luRS19_tf,const uint8_t[], -Variable,-,u8g2_font_luRS19_tn,const uint8_t[], -Variable,-,u8g2_font_luRS19_tr,const uint8_t[], -Variable,-,u8g2_font_luRS24_te,const uint8_t[], -Variable,-,u8g2_font_luRS24_tf,const uint8_t[], -Variable,-,u8g2_font_luRS24_tn,const uint8_t[], -Variable,-,u8g2_font_luRS24_tr,const uint8_t[], -Variable,-,u8g2_font_lubB08_te,const uint8_t[], -Variable,-,u8g2_font_lubB08_tf,const uint8_t[], -Variable,-,u8g2_font_lubB08_tn,const uint8_t[], -Variable,-,u8g2_font_lubB08_tr,const uint8_t[], -Variable,-,u8g2_font_lubB10_te,const uint8_t[], -Variable,-,u8g2_font_lubB10_tf,const uint8_t[], -Variable,-,u8g2_font_lubB10_tn,const uint8_t[], -Variable,-,u8g2_font_lubB10_tr,const uint8_t[], -Variable,-,u8g2_font_lubB12_te,const uint8_t[], -Variable,-,u8g2_font_lubB12_tf,const uint8_t[], -Variable,-,u8g2_font_lubB12_tn,const uint8_t[], -Variable,-,u8g2_font_lubB12_tr,const uint8_t[], -Variable,-,u8g2_font_lubB14_te,const uint8_t[], -Variable,-,u8g2_font_lubB14_tf,const uint8_t[], -Variable,-,u8g2_font_lubB14_tn,const uint8_t[], -Variable,-,u8g2_font_lubB14_tr,const uint8_t[], -Variable,-,u8g2_font_lubB18_te,const uint8_t[], -Variable,-,u8g2_font_lubB18_tf,const uint8_t[], -Variable,-,u8g2_font_lubB18_tn,const uint8_t[], -Variable,-,u8g2_font_lubB18_tr,const uint8_t[], -Variable,-,u8g2_font_lubB19_te,const uint8_t[], -Variable,-,u8g2_font_lubB19_tf,const uint8_t[], -Variable,-,u8g2_font_lubB19_tn,const uint8_t[], -Variable,-,u8g2_font_lubB19_tr,const uint8_t[], -Variable,-,u8g2_font_lubB24_te,const uint8_t[], -Variable,-,u8g2_font_lubB24_tf,const uint8_t[], -Variable,-,u8g2_font_lubB24_tn,const uint8_t[], -Variable,-,u8g2_font_lubB24_tr,const uint8_t[], -Variable,-,u8g2_font_lubBI08_te,const uint8_t[], -Variable,-,u8g2_font_lubBI08_tf,const uint8_t[], -Variable,-,u8g2_font_lubBI08_tn,const uint8_t[], -Variable,-,u8g2_font_lubBI08_tr,const uint8_t[], -Variable,-,u8g2_font_lubBI10_te,const uint8_t[], -Variable,-,u8g2_font_lubBI10_tf,const uint8_t[], -Variable,-,u8g2_font_lubBI10_tn,const uint8_t[], -Variable,-,u8g2_font_lubBI10_tr,const uint8_t[], -Variable,-,u8g2_font_lubBI12_te,const uint8_t[], -Variable,-,u8g2_font_lubBI12_tf,const uint8_t[], -Variable,-,u8g2_font_lubBI12_tn,const uint8_t[], -Variable,-,u8g2_font_lubBI12_tr,const uint8_t[], -Variable,-,u8g2_font_lubBI14_te,const uint8_t[], -Variable,-,u8g2_font_lubBI14_tf,const uint8_t[], -Variable,-,u8g2_font_lubBI14_tn,const uint8_t[], -Variable,-,u8g2_font_lubBI14_tr,const uint8_t[], -Variable,-,u8g2_font_lubBI18_te,const uint8_t[], -Variable,-,u8g2_font_lubBI18_tf,const uint8_t[], -Variable,-,u8g2_font_lubBI18_tn,const uint8_t[], -Variable,-,u8g2_font_lubBI18_tr,const uint8_t[], -Variable,-,u8g2_font_lubBI19_te,const uint8_t[], -Variable,-,u8g2_font_lubBI19_tf,const uint8_t[], -Variable,-,u8g2_font_lubBI19_tn,const uint8_t[], -Variable,-,u8g2_font_lubBI19_tr,const uint8_t[], -Variable,-,u8g2_font_lubBI24_te,const uint8_t[], -Variable,-,u8g2_font_lubBI24_tf,const uint8_t[], -Variable,-,u8g2_font_lubBI24_tn,const uint8_t[], -Variable,-,u8g2_font_lubBI24_tr,const uint8_t[], -Variable,-,u8g2_font_lubI08_te,const uint8_t[], -Variable,-,u8g2_font_lubI08_tf,const uint8_t[], -Variable,-,u8g2_font_lubI08_tn,const uint8_t[], -Variable,-,u8g2_font_lubI08_tr,const uint8_t[], -Variable,-,u8g2_font_lubI10_te,const uint8_t[], -Variable,-,u8g2_font_lubI10_tf,const uint8_t[], -Variable,-,u8g2_font_lubI10_tn,const uint8_t[], -Variable,-,u8g2_font_lubI10_tr,const uint8_t[], -Variable,-,u8g2_font_lubI12_te,const uint8_t[], -Variable,-,u8g2_font_lubI12_tf,const uint8_t[], -Variable,-,u8g2_font_lubI12_tn,const uint8_t[], -Variable,-,u8g2_font_lubI12_tr,const uint8_t[], -Variable,-,u8g2_font_lubI14_te,const uint8_t[], -Variable,-,u8g2_font_lubI14_tf,const uint8_t[], -Variable,-,u8g2_font_lubI14_tn,const uint8_t[], -Variable,-,u8g2_font_lubI14_tr,const uint8_t[], -Variable,-,u8g2_font_lubI18_te,const uint8_t[], -Variable,-,u8g2_font_lubI18_tf,const uint8_t[], -Variable,-,u8g2_font_lubI18_tn,const uint8_t[], -Variable,-,u8g2_font_lubI18_tr,const uint8_t[], -Variable,-,u8g2_font_lubI19_te,const uint8_t[], -Variable,-,u8g2_font_lubI19_tf,const uint8_t[], -Variable,-,u8g2_font_lubI19_tn,const uint8_t[], -Variable,-,u8g2_font_lubI19_tr,const uint8_t[], -Variable,-,u8g2_font_lubI24_te,const uint8_t[], -Variable,-,u8g2_font_lubI24_tf,const uint8_t[], -Variable,-,u8g2_font_lubI24_tn,const uint8_t[], -Variable,-,u8g2_font_lubI24_tr,const uint8_t[], -Variable,-,u8g2_font_lubR08_te,const uint8_t[], -Variable,-,u8g2_font_lubR08_tf,const uint8_t[], -Variable,-,u8g2_font_lubR08_tn,const uint8_t[], -Variable,-,u8g2_font_lubR08_tr,const uint8_t[], -Variable,-,u8g2_font_lubR10_te,const uint8_t[], -Variable,-,u8g2_font_lubR10_tf,const uint8_t[], -Variable,-,u8g2_font_lubR10_tn,const uint8_t[], -Variable,-,u8g2_font_lubR10_tr,const uint8_t[], -Variable,-,u8g2_font_lubR12_te,const uint8_t[], -Variable,-,u8g2_font_lubR12_tf,const uint8_t[], -Variable,-,u8g2_font_lubR12_tn,const uint8_t[], -Variable,-,u8g2_font_lubR12_tr,const uint8_t[], -Variable,-,u8g2_font_lubR14_te,const uint8_t[], -Variable,-,u8g2_font_lubR14_tf,const uint8_t[], -Variable,-,u8g2_font_lubR14_tn,const uint8_t[], -Variable,-,u8g2_font_lubR14_tr,const uint8_t[], -Variable,-,u8g2_font_lubR18_te,const uint8_t[], -Variable,-,u8g2_font_lubR18_tf,const uint8_t[], -Variable,-,u8g2_font_lubR18_tn,const uint8_t[], -Variable,-,u8g2_font_lubR18_tr,const uint8_t[], -Variable,-,u8g2_font_lubR19_te,const uint8_t[], -Variable,-,u8g2_font_lubR19_tf,const uint8_t[], -Variable,-,u8g2_font_lubR19_tn,const uint8_t[], -Variable,-,u8g2_font_lubR19_tr,const uint8_t[], -Variable,-,u8g2_font_lubR24_te,const uint8_t[], -Variable,-,u8g2_font_lubR24_tf,const uint8_t[], -Variable,-,u8g2_font_lubR24_tn,const uint8_t[], -Variable,-,u8g2_font_lubR24_tr,const uint8_t[], -Variable,-,u8g2_font_lucasarts_scumm_subtitle_o_tf,const uint8_t[], -Variable,-,u8g2_font_lucasarts_scumm_subtitle_o_tn,const uint8_t[], -Variable,-,u8g2_font_lucasarts_scumm_subtitle_o_tr,const uint8_t[], -Variable,-,u8g2_font_lucasarts_scumm_subtitle_r_tf,const uint8_t[], -Variable,-,u8g2_font_lucasarts_scumm_subtitle_r_tn,const uint8_t[], -Variable,-,u8g2_font_lucasarts_scumm_subtitle_r_tr,const uint8_t[], -Variable,-,u8g2_font_lucasfont_alternate_tf,const uint8_t[], -Variable,-,u8g2_font_lucasfont_alternate_tn,const uint8_t[], -Variable,-,u8g2_font_lucasfont_alternate_tr,const uint8_t[], -Variable,-,u8g2_font_m2icon_5_tf,const uint8_t[], -Variable,-,u8g2_font_m2icon_7_tf,const uint8_t[], -Variable,-,u8g2_font_m2icon_9_tf,const uint8_t[], -Variable,-,u8g2_font_mademoiselle_mel_tn,const uint8_t[], -Variable,-,u8g2_font_mademoiselle_mel_tr,const uint8_t[], -Variable,-,u8g2_font_maniac_te,const uint8_t[], -Variable,-,u8g2_font_maniac_tf,const uint8_t[], -Variable,-,u8g2_font_maniac_tn,const uint8_t[], -Variable,-,u8g2_font_maniac_tr,const uint8_t[], -Variable,-,u8g2_font_mercutio_basic_nbp_t_all,const uint8_t[], -Variable,-,u8g2_font_mercutio_basic_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_mercutio_basic_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_mercutio_basic_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_mercutio_sc_nbp_t_all,const uint8_t[], -Variable,-,u8g2_font_mercutio_sc_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_mercutio_sc_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_mercutio_sc_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_michaelmouse_tu,const uint8_t[], -Variable,-,u8g2_font_micro_mn,const uint8_t[], -Variable,-,u8g2_font_micro_mr,const uint8_t[], -Variable,-,u8g2_font_micro_tn,const uint8_t[], -Variable,-,u8g2_font_micro_tr,const uint8_t[], -Variable,-,u8g2_font_miranda_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_miranda_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_miranda_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_missingplanet_t_all,const uint8_t[], -Variable,-,u8g2_font_missingplanet_tf,const uint8_t[], -Variable,-,u8g2_font_missingplanet_tn,const uint8_t[], -Variable,-,u8g2_font_missingplanet_tr,const uint8_t[], -Variable,-,u8g2_font_mozart_nbp_h_all,const uint8_t[], -Variable,-,u8g2_font_mozart_nbp_t_all,const uint8_t[], -Variable,-,u8g2_font_mozart_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_mozart_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_mozart_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_ncenB08_te,const uint8_t[], -Variable,-,u8g2_font_ncenB08_tf,const uint8_t[], -Variable,-,u8g2_font_ncenB08_tn,const uint8_t[], -Variable,-,u8g2_font_ncenB08_tr,const uint8_t[], -Variable,-,u8g2_font_ncenB10_te,const uint8_t[], -Variable,-,u8g2_font_ncenB10_tf,const uint8_t[], -Variable,-,u8g2_font_ncenB10_tn,const uint8_t[], -Variable,-,u8g2_font_ncenB10_tr,const uint8_t[], -Variable,-,u8g2_font_ncenB12_te,const uint8_t[], -Variable,-,u8g2_font_ncenB12_tf,const uint8_t[], -Variable,-,u8g2_font_ncenB12_tn,const uint8_t[], -Variable,-,u8g2_font_ncenB12_tr,const uint8_t[], -Variable,-,u8g2_font_ncenB14_te,const uint8_t[], -Variable,-,u8g2_font_ncenB14_tf,const uint8_t[], -Variable,-,u8g2_font_ncenB14_tn,const uint8_t[], -Variable,-,u8g2_font_ncenB14_tr,const uint8_t[], -Variable,-,u8g2_font_ncenB18_te,const uint8_t[], -Variable,-,u8g2_font_ncenB18_tf,const uint8_t[], -Variable,-,u8g2_font_ncenB18_tn,const uint8_t[], -Variable,-,u8g2_font_ncenB18_tr,const uint8_t[], -Variable,-,u8g2_font_ncenB24_te,const uint8_t[], -Variable,-,u8g2_font_ncenB24_tf,const uint8_t[], -Variable,-,u8g2_font_ncenB24_tn,const uint8_t[], -Variable,-,u8g2_font_ncenB24_tr,const uint8_t[], -Variable,-,u8g2_font_ncenR08_te,const uint8_t[], -Variable,-,u8g2_font_ncenR08_tf,const uint8_t[], -Variable,-,u8g2_font_ncenR08_tn,const uint8_t[], -Variable,-,u8g2_font_ncenR08_tr,const uint8_t[], -Variable,-,u8g2_font_ncenR10_te,const uint8_t[], -Variable,-,u8g2_font_ncenR10_tf,const uint8_t[], -Variable,-,u8g2_font_ncenR10_tn,const uint8_t[], -Variable,-,u8g2_font_ncenR10_tr,const uint8_t[], -Variable,-,u8g2_font_ncenR12_te,const uint8_t[], -Variable,-,u8g2_font_ncenR12_tf,const uint8_t[], -Variable,-,u8g2_font_ncenR12_tn,const uint8_t[], -Variable,-,u8g2_font_ncenR12_tr,const uint8_t[], -Variable,-,u8g2_font_ncenR14_te,const uint8_t[], -Variable,-,u8g2_font_ncenR14_tf,const uint8_t[], -Variable,-,u8g2_font_ncenR14_tn,const uint8_t[], -Variable,-,u8g2_font_ncenR14_tr,const uint8_t[], -Variable,-,u8g2_font_ncenR18_te,const uint8_t[], -Variable,-,u8g2_font_ncenR18_tf,const uint8_t[], -Variable,-,u8g2_font_ncenR18_tn,const uint8_t[], -Variable,-,u8g2_font_ncenR18_tr,const uint8_t[], -Variable,-,u8g2_font_ncenR24_te,const uint8_t[], -Variable,-,u8g2_font_ncenR24_tf,const uint8_t[], -Variable,-,u8g2_font_ncenR24_tn,const uint8_t[], -Variable,-,u8g2_font_ncenR24_tr,const uint8_t[], -Variable,-,u8g2_font_nerhoe_tf,const uint8_t[], -Variable,-,u8g2_font_nerhoe_tn,const uint8_t[], -Variable,-,u8g2_font_nerhoe_tr,const uint8_t[], -Variable,-,u8g2_font_nine_by_five_nbp_t_all,const uint8_t[], -Variable,-,u8g2_font_nine_by_five_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_nine_by_five_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_nine_by_five_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_nokiafc22_tf,const uint8_t[], -Variable,-,u8g2_font_nokiafc22_tn,const uint8_t[], -Variable,-,u8g2_font_nokiafc22_tr,const uint8_t[], -Variable,-,u8g2_font_nokiafc22_tu,const uint8_t[], -Variable,-,u8g2_font_oldwizard_tf,const uint8_t[], -Variable,-,u8g2_font_oldwizard_tn,const uint8_t[], -Variable,-,u8g2_font_oldwizard_tr,const uint8_t[], -Variable,-,u8g2_font_oldwizard_tu,const uint8_t[], -Variable,-,u8g2_font_open_iconic_all_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_all_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_all_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_all_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_all_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_app_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_app_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_app_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_app_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_app_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_arrow_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_arrow_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_arrow_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_arrow_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_arrow_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_check_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_check_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_check_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_check_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_check_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_email_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_email_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_email_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_email_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_email_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_embedded_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_embedded_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_embedded_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_embedded_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_embedded_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_gui_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_gui_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_gui_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_gui_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_gui_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_human_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_human_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_human_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_human_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_human_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_mime_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_mime_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_mime_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_mime_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_mime_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_other_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_other_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_other_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_other_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_other_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_play_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_play_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_play_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_play_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_play_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_text_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_text_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_text_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_text_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_text_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_thing_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_thing_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_thing_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_thing_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_thing_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_weather_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_weather_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_weather_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_weather_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_weather_8x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_www_1x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_www_2x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_www_4x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_www_6x_t,const uint8_t[], -Variable,-,u8g2_font_open_iconic_www_8x_t,const uint8_t[], -Variable,-,u8g2_font_ordinarybasis_t_all,const uint8_t[], -Variable,-,u8g2_font_ordinarybasis_tf,const uint8_t[], -Variable,-,u8g2_font_ordinarybasis_tn,const uint8_t[], -Variable,-,u8g2_font_ordinarybasis_tr,const uint8_t[], -Variable,-,u8g2_font_osb18_tf,const uint8_t[], -Variable,-,u8g2_font_osb18_tn,const uint8_t[], -Variable,-,u8g2_font_osb18_tr,const uint8_t[], -Variable,-,u8g2_font_osb21_tf,const uint8_t[], -Variable,-,u8g2_font_osb21_tn,const uint8_t[], -Variable,-,u8g2_font_osb21_tr,const uint8_t[], -Variable,-,u8g2_font_osb26_tf,const uint8_t[], -Variable,-,u8g2_font_osb26_tn,const uint8_t[], -Variable,-,u8g2_font_osb26_tr,const uint8_t[], -Variable,-,u8g2_font_osb29_tf,const uint8_t[], -Variable,-,u8g2_font_osb29_tn,const uint8_t[], -Variable,-,u8g2_font_osb29_tr,const uint8_t[], -Variable,-,u8g2_font_osb35_tf,const uint8_t[], -Variable,-,u8g2_font_osb35_tn,const uint8_t[], -Variable,-,u8g2_font_osb35_tr,const uint8_t[], -Variable,-,u8g2_font_osb41_tf,const uint8_t[], -Variable,-,u8g2_font_osb41_tn,const uint8_t[], -Variable,-,u8g2_font_osb41_tr,const uint8_t[], -Variable,-,u8g2_font_oskool_tf,const uint8_t[], -Variable,-,u8g2_font_oskool_tn,const uint8_t[], -Variable,-,u8g2_font_oskool_tr,const uint8_t[], -Variable,-,u8g2_font_osr18_tf,const uint8_t[], -Variable,-,u8g2_font_osr18_tn,const uint8_t[], -Variable,-,u8g2_font_osr18_tr,const uint8_t[], -Variable,-,u8g2_font_osr21_tf,const uint8_t[], -Variable,-,u8g2_font_osr21_tn,const uint8_t[], -Variable,-,u8g2_font_osr21_tr,const uint8_t[], -Variable,-,u8g2_font_osr26_tf,const uint8_t[], -Variable,-,u8g2_font_osr26_tn,const uint8_t[], -Variable,-,u8g2_font_osr26_tr,const uint8_t[], -Variable,-,u8g2_font_osr29_tf,const uint8_t[], -Variable,-,u8g2_font_osr29_tn,const uint8_t[], -Variable,-,u8g2_font_osr29_tr,const uint8_t[], -Variable,-,u8g2_font_osr35_tf,const uint8_t[], -Variable,-,u8g2_font_osr35_tn,const uint8_t[], -Variable,-,u8g2_font_osr35_tr,const uint8_t[], -Variable,-,u8g2_font_osr41_tf,const uint8_t[], -Variable,-,u8g2_font_osr41_tn,const uint8_t[], -Variable,-,u8g2_font_osr41_tr,const uint8_t[], -Variable,-,u8g2_font_p01type_tf,const uint8_t[], -Variable,-,u8g2_font_p01type_tn,const uint8_t[], -Variable,-,u8g2_font_p01type_tr,const uint8_t[], -Variable,-,u8g2_font_pcsenior_8f,const uint8_t[], -Variable,-,u8g2_font_pcsenior_8n,const uint8_t[], -Variable,-,u8g2_font_pcsenior_8r,const uint8_t[], -Variable,-,u8g2_font_pcsenior_8u,const uint8_t[], -Variable,-,u8g2_font_pearfont_tr,const uint8_t[], -Variable,-,u8g2_font_pieceofcake_mel_tn,const uint8_t[], -Variable,-,u8g2_font_pieceofcake_mel_tr,const uint8_t[], -Variable,-,u8g2_font_pixelle_micro_tn,const uint8_t[], -Variable,-,u8g2_font_pixelle_micro_tr,const uint8_t[], -Variable,-,u8g2_font_pixelmordred_t_all,const uint8_t[], -Variable,-,u8g2_font_pixelmordred_tf,const uint8_t[], -Variable,-,u8g2_font_pixelmordred_tn,const uint8_t[], -Variable,-,u8g2_font_pixelmordred_tr,const uint8_t[], -Variable,-,u8g2_font_pixelpoiiz_tr,const uint8_t[], -Variable,-,u8g2_font_press_mel_tn,const uint8_t[], -Variable,-,u8g2_font_press_mel_tr,const uint8_t[], -Variable,-,u8g2_font_pressstart2p_8f,const uint8_t[], -Variable,-,u8g2_font_pressstart2p_8n,const uint8_t[], -Variable,-,u8g2_font_pressstart2p_8r,const uint8_t[], -Variable,-,u8g2_font_pressstart2p_8u,const uint8_t[], -Variable,-,u8g2_font_profont10_mf,const uint8_t[], -Variable,-,u8g2_font_profont10_mn,const uint8_t[], -Variable,-,u8g2_font_profont10_mr,const uint8_t[], -Variable,-,u8g2_font_profont10_tf,const uint8_t[], -Variable,-,u8g2_font_profont10_tn,const uint8_t[], -Variable,-,u8g2_font_profont10_tr,const uint8_t[], -Variable,-,u8g2_font_profont11_mf,const uint8_t[], -Variable,-,u8g2_font_profont11_mn,const uint8_t[], -Variable,-,u8g2_font_profont11_mr,const uint8_t[], -Variable,-,u8g2_font_profont11_tf,const uint8_t[], -Variable,-,u8g2_font_profont11_tn,const uint8_t[], -Variable,-,u8g2_font_profont11_tr,const uint8_t[], -Variable,-,u8g2_font_profont12_mf,const uint8_t[], -Variable,-,u8g2_font_profont12_mn,const uint8_t[], -Variable,-,u8g2_font_profont12_mr,const uint8_t[], -Variable,-,u8g2_font_profont12_tf,const uint8_t[], -Variable,-,u8g2_font_profont12_tn,const uint8_t[], -Variable,-,u8g2_font_profont12_tr,const uint8_t[], -Variable,-,u8g2_font_profont15_mf,const uint8_t[], -Variable,-,u8g2_font_profont15_mn,const uint8_t[], -Variable,-,u8g2_font_profont15_mr,const uint8_t[], -Variable,-,u8g2_font_profont15_tf,const uint8_t[], -Variable,-,u8g2_font_profont15_tn,const uint8_t[], -Variable,-,u8g2_font_profont15_tr,const uint8_t[], -Variable,-,u8g2_font_profont17_mf,const uint8_t[], -Variable,-,u8g2_font_profont17_mn,const uint8_t[], -Variable,-,u8g2_font_profont17_mr,const uint8_t[], -Variable,-,u8g2_font_profont17_tf,const uint8_t[], -Variable,-,u8g2_font_profont17_tn,const uint8_t[], -Variable,-,u8g2_font_profont17_tr,const uint8_t[], -Variable,-,u8g2_font_profont22_mf,const uint8_t[], -Variable,-,u8g2_font_profont22_mn,const uint8_t[], -Variable,-,u8g2_font_profont22_mr,const uint8_t[], -Variable,-,u8g2_font_profont22_tf,const uint8_t[], -Variable,-,u8g2_font_profont22_tn,const uint8_t[], -Variable,-,u8g2_font_profont22_tr,const uint8_t[], -Variable,-,u8g2_font_profont29_mf,const uint8_t[], -Variable,-,u8g2_font_profont29_mn,const uint8_t[], -Variable,-,u8g2_font_profont29_mr,const uint8_t[], -Variable,-,u8g2_font_profont29_tf,const uint8_t[], -Variable,-,u8g2_font_profont29_tn,const uint8_t[], -Variable,-,u8g2_font_profont29_tr,const uint8_t[], -Variable,-,u8g2_font_prospero_bold_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_prospero_bold_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_prospero_bold_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_prospero_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_prospero_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_prospero_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_px437wyse700a_mf,const uint8_t[], -Variable,-,u8g2_font_px437wyse700a_mn,const uint8_t[], -Variable,-,u8g2_font_px437wyse700a_mr,const uint8_t[], -Variable,-,u8g2_font_px437wyse700a_tf,const uint8_t[], -Variable,-,u8g2_font_px437wyse700a_tn,const uint8_t[], -Variable,-,u8g2_font_px437wyse700a_tr,const uint8_t[], -Variable,-,u8g2_font_px437wyse700b_mf,const uint8_t[], -Variable,-,u8g2_font_px437wyse700b_mn,const uint8_t[], -Variable,-,u8g2_font_px437wyse700b_mr,const uint8_t[], -Variable,-,u8g2_font_px437wyse700b_tf,const uint8_t[], -Variable,-,u8g2_font_px437wyse700b_tn,const uint8_t[], -Variable,-,u8g2_font_px437wyse700b_tr,const uint8_t[], -Variable,-,u8g2_font_pxplusibmcga_8f,const uint8_t[], -Variable,-,u8g2_font_pxplusibmcga_8n,const uint8_t[], -Variable,-,u8g2_font_pxplusibmcga_8r,const uint8_t[], -Variable,-,u8g2_font_pxplusibmcga_8u,const uint8_t[], -Variable,-,u8g2_font_pxplusibmcgathin_8f,const uint8_t[], -Variable,-,u8g2_font_pxplusibmcgathin_8n,const uint8_t[], -Variable,-,u8g2_font_pxplusibmcgathin_8r,const uint8_t[], -Variable,-,u8g2_font_pxplusibmcgathin_8u,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga8_m_all,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga8_mf,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga8_mn,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga8_mr,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga8_t_all,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga8_tf,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga8_tn,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga8_tr,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga9_m_all,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga9_mf,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga9_mn,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga9_mr,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga9_t_all,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga9_tf,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga9_tn,const uint8_t[], -Variable,-,u8g2_font_pxplusibmvga9_tr,const uint8_t[], -Variable,-,u8g2_font_pxplustandynewtv_8_all,const uint8_t[], -Variable,-,u8g2_font_pxplustandynewtv_8f,const uint8_t[], -Variable,-,u8g2_font_pxplustandynewtv_8n,const uint8_t[], -Variable,-,u8g2_font_pxplustandynewtv_8r,const uint8_t[], -Variable,-,u8g2_font_pxplustandynewtv_8u,const uint8_t[], -Variable,-,u8g2_font_pxplustandynewtv_t_all,const uint8_t[], -Variable,-,u8g2_font_questgiver_tr,const uint8_t[], -Variable,-,u8g2_font_repress_mel_tn,const uint8_t[], -Variable,-,u8g2_font_repress_mel_tr,const uint8_t[], -Variable,-,u8g2_font_robot_de_niro_tf,const uint8_t[], -Variable,-,u8g2_font_robot_de_niro_tn,const uint8_t[], -Variable,-,u8g2_font_robot_de_niro_tr,const uint8_t[], -Variable,-,u8g2_font_roentgen_nbp_h_all,const uint8_t[], -Variable,-,u8g2_font_roentgen_nbp_t_all,const uint8_t[], -Variable,-,u8g2_font_roentgen_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_roentgen_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_roentgen_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_rosencrantz_nbp_t_all,const uint8_t[], -Variable,-,u8g2_font_rosencrantz_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_rosencrantz_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_rosencrantz_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_saikyosansbold8_8n,const uint8_t[], -Variable,-,u8g2_font_saikyosansbold8_8u,const uint8_t[], -Variable,-,u8g2_font_samim_10_t_all,const uint8_t[], -Variable,-,u8g2_font_samim_12_t_all,const uint8_t[], -Variable,-,u8g2_font_samim_14_t_all,const uint8_t[], -Variable,-,u8g2_font_samim_16_t_all,const uint8_t[], -Variable,-,u8g2_font_samim_fd_10_t_all,const uint8_t[], -Variable,-,u8g2_font_samim_fd_12_t_all,const uint8_t[], -Variable,-,u8g2_font_samim_fd_14_t_all,const uint8_t[], -Variable,-,u8g2_font_samim_fd_16_t_all,const uint8_t[], -Variable,-,u8g2_font_sandyforest_tn,const uint8_t[], -Variable,-,u8g2_font_sandyforest_tr,const uint8_t[], -Variable,-,u8g2_font_sandyforest_tu,const uint8_t[], -Variable,-,u8g2_font_secretaryhand_t_all,const uint8_t[], -Variable,-,u8g2_font_secretaryhand_tf,const uint8_t[], -Variable,-,u8g2_font_secretaryhand_tn,const uint8_t[], -Variable,-,u8g2_font_secretaryhand_tr,const uint8_t[], -Variable,-,u8g2_font_seraphimb1_tr,const uint8_t[], -Variable,-,u8g2_font_shylock_nbp_t_all,const uint8_t[], -Variable,-,u8g2_font_shylock_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_shylock_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_shylock_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_siji_t_6x10,const uint8_t[], -Variable,-,u8g2_font_sirclive_tn,const uint8_t[], -Variable,-,u8g2_font_sirclive_tr,const uint8_t[], -Variable,-,u8g2_font_sirclivethebold_tn,const uint8_t[], -Variable,-,u8g2_font_sirclivethebold_tr,const uint8_t[], -Variable,-,u8g2_font_smart_patrol_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_smart_patrol_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_smart_patrol_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_squirrel_tn,const uint8_t[], -Variable,-,u8g2_font_squirrel_tr,const uint8_t[], -Variable,-,u8g2_font_squirrel_tu,const uint8_t[], -Variable,-,u8g2_font_sticker_mel_tn,const uint8_t[], -Variable,-,u8g2_font_sticker_mel_tr,const uint8_t[], -Variable,-,u8g2_font_synchronizer_nbp_tf,const uint8_t[], -Variable,-,u8g2_font_synchronizer_nbp_tn,const uint8_t[], -Variable,-,u8g2_font_synchronizer_nbp_tr,const uint8_t[], -Variable,-,u8g2_font_t0_11_me,const uint8_t[], -Variable,-,u8g2_font_t0_11_mf,const uint8_t[], -Variable,-,u8g2_font_t0_11_mn,const uint8_t[], -Variable,-,u8g2_font_t0_11_mr,const uint8_t[], -Variable,-,u8g2_font_t0_11_t_all,const uint8_t[], -Variable,-,u8g2_font_t0_11_te,const uint8_t[], -Variable,-,u8g2_font_t0_11_tf,const uint8_t[], -Variable,-,u8g2_font_t0_11_tn,const uint8_t[], -Variable,-,u8g2_font_t0_11_tr,const uint8_t[], -Variable,-,u8g2_font_t0_11b_me,const uint8_t[], -Variable,-,u8g2_font_t0_11b_mf,const uint8_t[], -Variable,-,u8g2_font_t0_11b_mn,const uint8_t[], -Variable,-,u8g2_font_t0_11b_mr,const uint8_t[], -Variable,-,u8g2_font_t0_11b_te,const uint8_t[], -Variable,-,u8g2_font_t0_11b_tf,const uint8_t[], -Variable,-,u8g2_font_t0_11b_tn,const uint8_t[], -Variable,-,u8g2_font_t0_11b_tr,const uint8_t[], -Variable,-,u8g2_font_t0_12_me,const uint8_t[], -Variable,-,u8g2_font_t0_12_mf,const uint8_t[], -Variable,-,u8g2_font_t0_12_mn,const uint8_t[], -Variable,-,u8g2_font_t0_12_mr,const uint8_t[], -Variable,-,u8g2_font_t0_12_te,const uint8_t[], -Variable,-,u8g2_font_t0_12_tf,const uint8_t[], -Variable,-,u8g2_font_t0_12_tn,const uint8_t[], -Variable,-,u8g2_font_t0_12_tr,const uint8_t[], -Variable,-,u8g2_font_t0_12b_me,const uint8_t[], -Variable,-,u8g2_font_t0_12b_mf,const uint8_t[], -Variable,-,u8g2_font_t0_12b_mn,const uint8_t[], -Variable,-,u8g2_font_t0_12b_mr,const uint8_t[], -Variable,-,u8g2_font_t0_12b_te,const uint8_t[], -Variable,-,u8g2_font_t0_12b_tf,const uint8_t[], -Variable,-,u8g2_font_t0_12b_tn,const uint8_t[], -Variable,-,u8g2_font_t0_12b_tr,const uint8_t[], -Variable,-,u8g2_font_t0_13_me,const uint8_t[], -Variable,-,u8g2_font_t0_13_mf,const uint8_t[], -Variable,-,u8g2_font_t0_13_mn,const uint8_t[], -Variable,-,u8g2_font_t0_13_mr,const uint8_t[], -Variable,-,u8g2_font_t0_13_te,const uint8_t[], -Variable,-,u8g2_font_t0_13_tf,const uint8_t[], -Variable,-,u8g2_font_t0_13_tn,const uint8_t[], -Variable,-,u8g2_font_t0_13_tr,const uint8_t[], -Variable,-,u8g2_font_t0_13b_me,const uint8_t[], -Variable,-,u8g2_font_t0_13b_mf,const uint8_t[], -Variable,-,u8g2_font_t0_13b_mn,const uint8_t[], -Variable,-,u8g2_font_t0_13b_mr,const uint8_t[], -Variable,-,u8g2_font_t0_13b_te,const uint8_t[], -Variable,-,u8g2_font_t0_13b_tf,const uint8_t[], -Variable,-,u8g2_font_t0_13b_tn,const uint8_t[], -Variable,-,u8g2_font_t0_13b_tr,const uint8_t[], -Variable,-,u8g2_font_t0_14_me,const uint8_t[], -Variable,-,u8g2_font_t0_14_mf,const uint8_t[], -Variable,-,u8g2_font_t0_14_mn,const uint8_t[], -Variable,-,u8g2_font_t0_14_mr,const uint8_t[], -Variable,-,u8g2_font_t0_14_te,const uint8_t[], -Variable,-,u8g2_font_t0_14_tf,const uint8_t[], -Variable,-,u8g2_font_t0_14_tn,const uint8_t[], -Variable,-,u8g2_font_t0_14_tr,const uint8_t[], -Variable,-,u8g2_font_t0_14b_me,const uint8_t[], -Variable,-,u8g2_font_t0_14b_mf,const uint8_t[], -Variable,-,u8g2_font_t0_14b_mn,const uint8_t[], -Variable,-,u8g2_font_t0_14b_mr,const uint8_t[], -Variable,-,u8g2_font_t0_14b_te,const uint8_t[], -Variable,-,u8g2_font_t0_14b_tf,const uint8_t[], -Variable,-,u8g2_font_t0_14b_tn,const uint8_t[], -Variable,-,u8g2_font_t0_14b_tr,const uint8_t[], -Variable,-,u8g2_font_t0_15_me,const uint8_t[], -Variable,-,u8g2_font_t0_15_mf,const uint8_t[], -Variable,-,u8g2_font_t0_15_mn,const uint8_t[], -Variable,-,u8g2_font_t0_15_mr,const uint8_t[], -Variable,-,u8g2_font_t0_15_te,const uint8_t[], -Variable,-,u8g2_font_t0_15_tf,const uint8_t[], -Variable,-,u8g2_font_t0_15_tn,const uint8_t[], -Variable,-,u8g2_font_t0_15_tr,const uint8_t[], -Variable,-,u8g2_font_t0_15b_me,const uint8_t[], -Variable,-,u8g2_font_t0_15b_mf,const uint8_t[], -Variable,-,u8g2_font_t0_15b_mn,const uint8_t[], -Variable,-,u8g2_font_t0_15b_mr,const uint8_t[], -Variable,-,u8g2_font_t0_15b_te,const uint8_t[], -Variable,-,u8g2_font_t0_15b_tf,const uint8_t[], -Variable,-,u8g2_font_t0_15b_tn,const uint8_t[], -Variable,-,u8g2_font_t0_15b_tr,const uint8_t[], -Variable,-,u8g2_font_t0_16_me,const uint8_t[], -Variable,-,u8g2_font_t0_16_mf,const uint8_t[], -Variable,-,u8g2_font_t0_16_mn,const uint8_t[], -Variable,-,u8g2_font_t0_16_mr,const uint8_t[], -Variable,-,u8g2_font_t0_16_te,const uint8_t[], -Variable,-,u8g2_font_t0_16_tf,const uint8_t[], -Variable,-,u8g2_font_t0_16_tn,const uint8_t[], -Variable,-,u8g2_font_t0_16_tr,const uint8_t[], -Variable,-,u8g2_font_t0_16b_me,const uint8_t[], -Variable,-,u8g2_font_t0_16b_mf,const uint8_t[], -Variable,-,u8g2_font_t0_16b_mn,const uint8_t[], -Variable,-,u8g2_font_t0_16b_mr,const uint8_t[], -Variable,-,u8g2_font_t0_16b_te,const uint8_t[], -Variable,-,u8g2_font_t0_16b_tf,const uint8_t[], -Variable,-,u8g2_font_t0_16b_tn,const uint8_t[], -Variable,-,u8g2_font_t0_16b_tr,const uint8_t[], -Variable,-,u8g2_font_t0_17_me,const uint8_t[], -Variable,-,u8g2_font_t0_17_mf,const uint8_t[], -Variable,-,u8g2_font_t0_17_mn,const uint8_t[], -Variable,-,u8g2_font_t0_17_mr,const uint8_t[], -Variable,-,u8g2_font_t0_17_te,const uint8_t[], -Variable,-,u8g2_font_t0_17_tf,const uint8_t[], -Variable,-,u8g2_font_t0_17_tn,const uint8_t[], -Variable,-,u8g2_font_t0_17_tr,const uint8_t[], -Variable,-,u8g2_font_t0_17b_me,const uint8_t[], -Variable,-,u8g2_font_t0_17b_mf,const uint8_t[], -Variable,-,u8g2_font_t0_17b_mn,const uint8_t[], -Variable,-,u8g2_font_t0_17b_mr,const uint8_t[], -Variable,-,u8g2_font_t0_17b_te,const uint8_t[], -Variable,-,u8g2_font_t0_17b_tf,const uint8_t[], -Variable,-,u8g2_font_t0_17b_tn,const uint8_t[], -Variable,-,u8g2_font_t0_17b_tr,const uint8_t[], -Variable,-,u8g2_font_t0_18_me,const uint8_t[], -Variable,-,u8g2_font_t0_18_mf,const uint8_t[], -Variable,-,u8g2_font_t0_18_mn,const uint8_t[], -Variable,-,u8g2_font_t0_18_mr,const uint8_t[], -Variable,-,u8g2_font_t0_18_te,const uint8_t[], -Variable,-,u8g2_font_t0_18_tf,const uint8_t[], -Variable,-,u8g2_font_t0_18_tn,const uint8_t[], -Variable,-,u8g2_font_t0_18_tr,const uint8_t[], -Variable,-,u8g2_font_t0_18b_me,const uint8_t[], -Variable,-,u8g2_font_t0_18b_mf,const uint8_t[], -Variable,-,u8g2_font_t0_18b_mn,const uint8_t[], -Variable,-,u8g2_font_t0_18b_mr,const uint8_t[], -Variable,-,u8g2_font_t0_18b_te,const uint8_t[], -Variable,-,u8g2_font_t0_18b_tf,const uint8_t[], -Variable,-,u8g2_font_t0_18b_tn,const uint8_t[], -Variable,-,u8g2_font_t0_18b_tr,const uint8_t[], -Variable,-,u8g2_font_t0_22_me,const uint8_t[], -Variable,-,u8g2_font_t0_22_mf,const uint8_t[], -Variable,-,u8g2_font_t0_22_mn,const uint8_t[], -Variable,-,u8g2_font_t0_22_mr,const uint8_t[], -Variable,-,u8g2_font_t0_22_te,const uint8_t[], -Variable,-,u8g2_font_t0_22_tf,const uint8_t[], -Variable,-,u8g2_font_t0_22_tn,const uint8_t[], -Variable,-,u8g2_font_t0_22_tr,const uint8_t[], -Variable,-,u8g2_font_t0_22b_me,const uint8_t[], -Variable,-,u8g2_font_t0_22b_mf,const uint8_t[], -Variable,-,u8g2_font_t0_22b_mn,const uint8_t[], -Variable,-,u8g2_font_t0_22b_mr,const uint8_t[], -Variable,-,u8g2_font_t0_22b_te,const uint8_t[], -Variable,-,u8g2_font_t0_22b_tf,const uint8_t[], -Variable,-,u8g2_font_t0_22b_tn,const uint8_t[], -Variable,-,u8g2_font_t0_22b_tr,const uint8_t[], -Variable,-,u8g2_font_tallpix_tr,const uint8_t[], -Variable,-,u8g2_font_tenfatguys_t_all,const uint8_t[], -Variable,-,u8g2_font_tenfatguys_tf,const uint8_t[], -Variable,-,u8g2_font_tenfatguys_tn,const uint8_t[], -Variable,-,u8g2_font_tenfatguys_tr,const uint8_t[], -Variable,-,u8g2_font_tenfatguys_tu,const uint8_t[], -Variable,-,u8g2_font_tenstamps_mf,const uint8_t[], -Variable,-,u8g2_font_tenstamps_mn,const uint8_t[], -Variable,-,u8g2_font_tenstamps_mr,const uint8_t[], -Variable,-,u8g2_font_tenstamps_mu,const uint8_t[], -Variable,-,u8g2_font_tenthinguys_t_all,const uint8_t[], -Variable,-,u8g2_font_tenthinguys_tf,const uint8_t[], -Variable,-,u8g2_font_tenthinguys_tn,const uint8_t[], -Variable,-,u8g2_font_tenthinguys_tr,const uint8_t[], -Variable,-,u8g2_font_tenthinguys_tu,const uint8_t[], -Variable,-,u8g2_font_tenthinnerguys_t_all,const uint8_t[], -Variable,-,u8g2_font_tenthinnerguys_tf,const uint8_t[], -Variable,-,u8g2_font_tenthinnerguys_tn,const uint8_t[], -Variable,-,u8g2_font_tenthinnerguys_tr,const uint8_t[], -Variable,-,u8g2_font_tenthinnerguys_tu,const uint8_t[], -Variable,-,u8g2_font_timB08_tf,const uint8_t[], -Variable,-,u8g2_font_timB08_tn,const uint8_t[], -Variable,-,u8g2_font_timB08_tr,const uint8_t[], -Variable,-,u8g2_font_timB10_tf,const uint8_t[], -Variable,-,u8g2_font_timB10_tn,const uint8_t[], -Variable,-,u8g2_font_timB10_tr,const uint8_t[], -Variable,-,u8g2_font_timB12_tf,const uint8_t[], -Variable,-,u8g2_font_timB12_tn,const uint8_t[], -Variable,-,u8g2_font_timB12_tr,const uint8_t[], -Variable,-,u8g2_font_timB14_tf,const uint8_t[], -Variable,-,u8g2_font_timB14_tn,const uint8_t[], -Variable,-,u8g2_font_timB14_tr,const uint8_t[], -Variable,-,u8g2_font_timB18_tf,const uint8_t[], -Variable,-,u8g2_font_timB18_tn,const uint8_t[], -Variable,-,u8g2_font_timB18_tr,const uint8_t[], -Variable,-,u8g2_font_timB24_tf,const uint8_t[], -Variable,-,u8g2_font_timB24_tn,const uint8_t[], -Variable,-,u8g2_font_timB24_tr,const uint8_t[], -Variable,-,u8g2_font_timR08_tf,const uint8_t[], -Variable,-,u8g2_font_timR08_tn,const uint8_t[], -Variable,-,u8g2_font_timR08_tr,const uint8_t[], -Variable,-,u8g2_font_timR10_tf,const uint8_t[], -Variable,-,u8g2_font_timR10_tn,const uint8_t[], -Variable,-,u8g2_font_timR10_tr,const uint8_t[], -Variable,-,u8g2_font_timR12_tf,const uint8_t[], -Variable,-,u8g2_font_timR12_tn,const uint8_t[], -Variable,-,u8g2_font_timR12_tr,const uint8_t[], -Variable,-,u8g2_font_timR14_tf,const uint8_t[], -Variable,-,u8g2_font_timR14_tn,const uint8_t[], -Variable,-,u8g2_font_timR14_tr,const uint8_t[], -Variable,-,u8g2_font_timR18_tf,const uint8_t[], -Variable,-,u8g2_font_timR18_tn,const uint8_t[], -Variable,-,u8g2_font_timR18_tr,const uint8_t[], -Variable,-,u8g2_font_timR24_tf,const uint8_t[], -Variable,-,u8g2_font_timR24_tn,const uint8_t[], -Variable,-,u8g2_font_timR24_tr,const uint8_t[], -Variable,-,u8g2_font_tinytim_tf,const uint8_t[], -Variable,-,u8g2_font_tinytim_tn,const uint8_t[], -Variable,-,u8g2_font_tinytim_tr,const uint8_t[], -Variable,-,u8g2_font_tom_thumb_4x6_me,const uint8_t[], -Variable,-,u8g2_font_tom_thumb_4x6_mf,const uint8_t[], -Variable,-,u8g2_font_tom_thumb_4x6_mn,const uint8_t[], -Variable,-,u8g2_font_tom_thumb_4x6_mr,const uint8_t[], -Variable,-,u8g2_font_tom_thumb_4x6_t_all,const uint8_t[], -Variable,-,u8g2_font_tom_thumb_4x6_te,const uint8_t[], -Variable,-,u8g2_font_tom_thumb_4x6_tf,const uint8_t[], -Variable,-,u8g2_font_tom_thumb_4x6_tn,const uint8_t[], -Variable,-,u8g2_font_tom_thumb_4x6_tr,const uint8_t[], -Variable,-,u8g2_font_tooseornament_tf,const uint8_t[], -Variable,-,u8g2_font_tooseornament_tn,const uint8_t[], -Variable,-,u8g2_font_tooseornament_tr,const uint8_t[], -Variable,-,u8g2_font_torussansbold8_8n,const uint8_t[], -Variable,-,u8g2_font_torussansbold8_8r,const uint8_t[], -Variable,-,u8g2_font_torussansbold8_8u,const uint8_t[], -Variable,-,u8g2_font_trixel_square_tf,const uint8_t[], -Variable,-,u8g2_font_trixel_square_tn,const uint8_t[], -Variable,-,u8g2_font_trixel_square_tr,const uint8_t[], -Variable,-,u8g2_font_twelvedings_t_all,const uint8_t[], -Variable,-,u8g2_font_u8glib_4_hf,const uint8_t[], -Variable,-,u8g2_font_u8glib_4_hr,const uint8_t[], -Variable,-,u8g2_font_u8glib_4_tf,const uint8_t[], -Variable,-,u8g2_font_u8glib_4_tr,const uint8_t[], -Variable,-,u8g2_font_unifont_h_symbols,const uint8_t[], -Variable,-,u8g2_font_unifont_t_0_72_73,const uint8_t[], -Variable,-,u8g2_font_unifont_t_0_75,const uint8_t[], -Variable,-,u8g2_font_unifont_t_0_76,const uint8_t[], -Variable,-,u8g2_font_unifont_t_0_77,const uint8_t[], -Variable,-,u8g2_font_unifont_t_0_78_79,const uint8_t[], -Variable,-,u8g2_font_unifont_t_0_86,const uint8_t[], -Variable,-,u8g2_font_unifont_t_72_73,const uint8_t[], -Variable,-,u8g2_font_unifont_t_75,const uint8_t[], -Variable,-,u8g2_font_unifont_t_76,const uint8_t[], -Variable,-,u8g2_font_unifont_t_77,const uint8_t[], -Variable,-,u8g2_font_unifont_t_78_79,const uint8_t[], -Variable,-,u8g2_font_unifont_t_86,const uint8_t[], -Variable,-,u8g2_font_unifont_t_animals,const uint8_t[], -Variable,-,u8g2_font_unifont_t_arabic,const uint8_t[], -Variable,-,u8g2_font_unifont_t_bengali,const uint8_t[], -Variable,-,u8g2_font_unifont_t_cards,const uint8_t[], -Variable,-,u8g2_font_unifont_t_chinese1,const uint8_t[], -Variable,-,u8g2_font_unifont_t_chinese2,const uint8_t[], -Variable,-,u8g2_font_unifont_t_chinese3,const uint8_t[], -Variable,-,u8g2_font_unifont_t_cyrillic,const uint8_t[], -Variable,-,u8g2_font_unifont_t_devanagari,const uint8_t[], -Variable,-,u8g2_font_unifont_t_domino,const uint8_t[], -Variable,-,u8g2_font_unifont_t_emoticons,const uint8_t[], -Variable,-,u8g2_font_unifont_t_extended,const uint8_t[], -Variable,-,u8g2_font_unifont_t_greek,const uint8_t[], -Variable,-,u8g2_font_unifont_t_hebrew,const uint8_t[], -Variable,-,u8g2_font_unifont_t_japanese1,const uint8_t[], -Variable,-,u8g2_font_unifont_t_japanese2,const uint8_t[], -Variable,-,u8g2_font_unifont_t_japanese3,const uint8_t[], -Variable,-,u8g2_font_unifont_t_korean1,const uint8_t[], -Variable,-,u8g2_font_unifont_t_korean2,const uint8_t[], -Variable,-,u8g2_font_unifont_t_latin,const uint8_t[], -Variable,-,u8g2_font_unifont_t_polish,const uint8_t[], -Variable,-,u8g2_font_unifont_t_symbols,const uint8_t[], -Variable,-,u8g2_font_unifont_t_tibetan,const uint8_t[], -Variable,-,u8g2_font_unifont_t_urdu,const uint8_t[], -Variable,-,u8g2_font_unifont_t_vietnamese1,const uint8_t[], -Variable,-,u8g2_font_unifont_t_vietnamese2,const uint8_t[], -Variable,-,u8g2_font_unifont_t_weather,const uint8_t[], -Variable,-,u8g2_font_unifont_te,const uint8_t[], -Variable,-,u8g2_font_unifont_tf,const uint8_t[], -Variable,-,u8g2_font_unifont_tr,const uint8_t[], -Variable,-,u8g2_font_victoriabold8_8n,const uint8_t[], -Variable,-,u8g2_font_victoriabold8_8r,const uint8_t[], -Variable,-,u8g2_font_victoriabold8_8u,const uint8_t[], -Variable,-,u8g2_font_victoriamedium8_8n,const uint8_t[], -Variable,-,u8g2_font_victoriamedium8_8r,const uint8_t[], -Variable,-,u8g2_font_victoriamedium8_8u,const uint8_t[], -Variable,-,u8g2_font_wqy12_t_chinese1,const uint8_t[], -Variable,-,u8g2_font_wqy12_t_chinese2,const uint8_t[], -Variable,-,u8g2_font_wqy12_t_chinese3,const uint8_t[], -Variable,-,u8g2_font_wqy12_t_gb2312,const uint8_t[], -Variable,-,u8g2_font_wqy12_t_gb2312a,const uint8_t[], -Variable,-,u8g2_font_wqy12_t_gb2312b,const uint8_t[], -Variable,-,u8g2_font_wqy13_t_chinese1,const uint8_t[], -Variable,-,u8g2_font_wqy13_t_chinese2,const uint8_t[], -Variable,-,u8g2_font_wqy13_t_chinese3,const uint8_t[], -Variable,-,u8g2_font_wqy13_t_gb2312,const uint8_t[], -Variable,-,u8g2_font_wqy13_t_gb2312a,const uint8_t[], -Variable,-,u8g2_font_wqy13_t_gb2312b,const uint8_t[], -Variable,-,u8g2_font_wqy14_t_chinese1,const uint8_t[], -Variable,-,u8g2_font_wqy14_t_chinese2,const uint8_t[], -Variable,-,u8g2_font_wqy14_t_chinese3,const uint8_t[], -Variable,-,u8g2_font_wqy14_t_gb2312,const uint8_t[], -Variable,-,u8g2_font_wqy14_t_gb2312a,const uint8_t[], -Variable,-,u8g2_font_wqy14_t_gb2312b,const uint8_t[], -Variable,-,u8g2_font_wqy15_t_chinese1,const uint8_t[], -Variable,-,u8g2_font_wqy15_t_chinese2,const uint8_t[], -Variable,-,u8g2_font_wqy15_t_chinese3,const uint8_t[], -Variable,-,u8g2_font_wqy15_t_gb2312,const uint8_t[], -Variable,-,u8g2_font_wqy15_t_gb2312a,const uint8_t[], -Variable,-,u8g2_font_wqy15_t_gb2312b,const uint8_t[], -Variable,-,u8g2_font_wqy16_t_chinese1,const uint8_t[], -Variable,-,u8g2_font_wqy16_t_chinese2,const uint8_t[], -Variable,-,u8g2_font_wqy16_t_chinese3,const uint8_t[], -Variable,-,u8g2_font_wqy16_t_gb2312,const uint8_t[], -Variable,-,u8g2_font_wqy16_t_gb2312a,const uint8_t[], -Variable,-,u8g2_font_wqy16_t_gb2312b,const uint8_t[], -Variable,-,u8x8_font_5x7_f,const uint8_t[], -Variable,-,u8x8_font_5x7_n,const uint8_t[], -Variable,-,u8x8_font_5x7_r,const uint8_t[], -Variable,-,u8x8_font_5x8_f,const uint8_t[], -Variable,-,u8x8_font_5x8_n,const uint8_t[], -Variable,-,u8x8_font_5x8_r,const uint8_t[], -Variable,-,u8x8_font_7x14B_1x2_f,const uint8_t[], -Variable,-,u8x8_font_7x14B_1x2_n,const uint8_t[], -Variable,-,u8x8_font_7x14B_1x2_r,const uint8_t[], -Variable,-,u8x8_font_7x14_1x2_f,const uint8_t[], -Variable,-,u8x8_font_7x14_1x2_n,const uint8_t[], -Variable,-,u8x8_font_7x14_1x2_r,const uint8_t[], -Variable,-,u8x8_font_8x13B_1x2_f,const uint8_t[], -Variable,-,u8x8_font_8x13B_1x2_n,const uint8_t[], -Variable,-,u8x8_font_8x13B_1x2_r,const uint8_t[], -Variable,-,u8x8_font_8x13_1x2_f,const uint8_t[], -Variable,-,u8x8_font_8x13_1x2_n,const uint8_t[], -Variable,-,u8x8_font_8x13_1x2_r,const uint8_t[], -Variable,-,u8x8_font_amstrad_cpc_extended_f,const uint8_t[], -Variable,-,u8x8_font_amstrad_cpc_extended_n,const uint8_t[], -Variable,-,u8x8_font_amstrad_cpc_extended_r,const uint8_t[], -Variable,-,u8x8_font_amstrad_cpc_extended_u,const uint8_t[], -Variable,-,u8x8_font_artossans8_n,const uint8_t[], -Variable,-,u8x8_font_artossans8_r,const uint8_t[], -Variable,-,u8x8_font_artossans8_u,const uint8_t[], -Variable,-,u8x8_font_artosserif8_n,const uint8_t[], -Variable,-,u8x8_font_artosserif8_r,const uint8_t[], -Variable,-,u8x8_font_artosserif8_u,const uint8_t[], -Variable,-,u8x8_font_chroma48medium8_n,const uint8_t[], -Variable,-,u8x8_font_chroma48medium8_r,const uint8_t[], -Variable,-,u8x8_font_chroma48medium8_u,const uint8_t[], -Variable,-,u8x8_font_courB18_2x3_f,const uint8_t[], -Variable,-,u8x8_font_courB18_2x3_n,const uint8_t[], -Variable,-,u8x8_font_courB18_2x3_r,const uint8_t[], -Variable,-,u8x8_font_courB24_3x4_f,const uint8_t[], -Variable,-,u8x8_font_courB24_3x4_n,const uint8_t[], -Variable,-,u8x8_font_courB24_3x4_r,const uint8_t[], -Variable,-,u8x8_font_courR18_2x3_f,const uint8_t[], -Variable,-,u8x8_font_courR18_2x3_n,const uint8_t[], -Variable,-,u8x8_font_courR18_2x3_r,const uint8_t[], -Variable,-,u8x8_font_courR24_3x4_f,const uint8_t[], -Variable,-,u8x8_font_courR24_3x4_n,const uint8_t[], -Variable,-,u8x8_font_courR24_3x4_r,const uint8_t[], -Variable,-,u8x8_font_inb21_2x4_f,const uint8_t[], -Variable,-,u8x8_font_inb21_2x4_n,const uint8_t[], -Variable,-,u8x8_font_inb21_2x4_r,const uint8_t[], -Variable,-,u8x8_font_inb33_3x6_f,const uint8_t[], -Variable,-,u8x8_font_inb33_3x6_n,const uint8_t[], -Variable,-,u8x8_font_inb33_3x6_r,const uint8_t[], -Variable,-,u8x8_font_inb46_4x8_f,const uint8_t[], -Variable,-,u8x8_font_inb46_4x8_n,const uint8_t[], -Variable,-,u8x8_font_inb46_4x8_r,const uint8_t[], -Variable,-,u8x8_font_inr21_2x4_f,const uint8_t[], -Variable,-,u8x8_font_inr21_2x4_n,const uint8_t[], -Variable,-,u8x8_font_inr21_2x4_r,const uint8_t[], -Variable,-,u8x8_font_inr33_3x6_f,const uint8_t[], -Variable,-,u8x8_font_inr33_3x6_n,const uint8_t[], -Variable,-,u8x8_font_inr33_3x6_r,const uint8_t[], -Variable,-,u8x8_font_inr46_4x8_f,const uint8_t[], -Variable,-,u8x8_font_inr46_4x8_n,const uint8_t[], -Variable,-,u8x8_font_inr46_4x8_r,const uint8_t[], -Variable,-,u8x8_font_lucasarts_scumm_subtitle_o_2x2_f,const uint8_t[], -Variable,-,u8x8_font_lucasarts_scumm_subtitle_o_2x2_n,const uint8_t[], -Variable,-,u8x8_font_lucasarts_scumm_subtitle_o_2x2_r,const uint8_t[], -Variable,-,u8x8_font_lucasarts_scumm_subtitle_r_2x2_f,const uint8_t[], -Variable,-,u8x8_font_lucasarts_scumm_subtitle_r_2x2_n,const uint8_t[], -Variable,-,u8x8_font_lucasarts_scumm_subtitle_r_2x2_r,const uint8_t[], -Variable,-,u8x8_font_open_iconic_arrow_1x1,const uint8_t[], -Variable,-,u8x8_font_open_iconic_arrow_2x2,const uint8_t[], -Variable,-,u8x8_font_open_iconic_arrow_4x4,const uint8_t[], -Variable,-,u8x8_font_open_iconic_arrow_8x8,const uint8_t[], -Variable,-,u8x8_font_open_iconic_check_1x1,const uint8_t[], -Variable,-,u8x8_font_open_iconic_check_2x2,const uint8_t[], -Variable,-,u8x8_font_open_iconic_check_4x4,const uint8_t[], -Variable,-,u8x8_font_open_iconic_check_8x8,const uint8_t[], -Variable,-,u8x8_font_open_iconic_embedded_1x1,const uint8_t[], -Variable,-,u8x8_font_open_iconic_embedded_2x2,const uint8_t[], -Variable,-,u8x8_font_open_iconic_embedded_4x4,const uint8_t[], -Variable,-,u8x8_font_open_iconic_embedded_8x8,const uint8_t[], -Variable,-,u8x8_font_open_iconic_play_1x1,const uint8_t[], -Variable,-,u8x8_font_open_iconic_play_2x2,const uint8_t[], -Variable,-,u8x8_font_open_iconic_play_4x4,const uint8_t[], -Variable,-,u8x8_font_open_iconic_play_8x8,const uint8_t[], -Variable,-,u8x8_font_open_iconic_thing_1x1,const uint8_t[], -Variable,-,u8x8_font_open_iconic_thing_2x2,const uint8_t[], -Variable,-,u8x8_font_open_iconic_thing_4x4,const uint8_t[], -Variable,-,u8x8_font_open_iconic_thing_8x8,const uint8_t[], -Variable,-,u8x8_font_open_iconic_weather_1x1,const uint8_t[], -Variable,-,u8x8_font_open_iconic_weather_2x2,const uint8_t[], -Variable,-,u8x8_font_open_iconic_weather_4x4,const uint8_t[], -Variable,-,u8x8_font_open_iconic_weather_8x8,const uint8_t[], -Variable,-,u8x8_font_pcsenior_f,const uint8_t[], -Variable,-,u8x8_font_pcsenior_n,const uint8_t[], -Variable,-,u8x8_font_pcsenior_r,const uint8_t[], -Variable,-,u8x8_font_pcsenior_u,const uint8_t[], -Variable,-,u8x8_font_pressstart2p_f,const uint8_t[], -Variable,-,u8x8_font_pressstart2p_n,const uint8_t[], -Variable,-,u8x8_font_pressstart2p_r,const uint8_t[], -Variable,-,u8x8_font_pressstart2p_u,const uint8_t[], -Variable,-,u8x8_font_profont29_2x3_f,const uint8_t[], -Variable,-,u8x8_font_profont29_2x3_n,const uint8_t[], -Variable,-,u8x8_font_profont29_2x3_r,const uint8_t[], -Variable,-,u8x8_font_px437wyse700a_2x2_f,const uint8_t[], -Variable,-,u8x8_font_px437wyse700a_2x2_n,const uint8_t[], -Variable,-,u8x8_font_px437wyse700a_2x2_r,const uint8_t[], -Variable,-,u8x8_font_px437wyse700b_2x2_f,const uint8_t[], -Variable,-,u8x8_font_px437wyse700b_2x2_n,const uint8_t[], -Variable,-,u8x8_font_px437wyse700b_2x2_r,const uint8_t[], -Variable,-,u8x8_font_pxplusibmcga_f,const uint8_t[], -Variable,-,u8x8_font_pxplusibmcga_n,const uint8_t[], -Variable,-,u8x8_font_pxplusibmcga_r,const uint8_t[], -Variable,-,u8x8_font_pxplusibmcga_u,const uint8_t[], -Variable,-,u8x8_font_pxplusibmcgathin_f,const uint8_t[], -Variable,-,u8x8_font_pxplusibmcgathin_n,const uint8_t[], -Variable,-,u8x8_font_pxplusibmcgathin_r,const uint8_t[], -Variable,-,u8x8_font_pxplusibmcgathin_u,const uint8_t[], -Variable,-,u8x8_font_pxplustandynewtv_f,const uint8_t[], -Variable,-,u8x8_font_pxplustandynewtv_n,const uint8_t[], -Variable,-,u8x8_font_pxplustandynewtv_r,const uint8_t[], -Variable,-,u8x8_font_pxplustandynewtv_u,const uint8_t[], -Variable,-,u8x8_font_saikyosansbold8_n,const uint8_t[], -Variable,-,u8x8_font_saikyosansbold8_u,const uint8_t[], -Variable,-,u8x8_font_torussansbold8_n,const uint8_t[], -Variable,-,u8x8_font_torussansbold8_r,const uint8_t[], -Variable,-,u8x8_font_torussansbold8_u,const uint8_t[], -Variable,-,u8x8_font_victoriabold8_n,const uint8_t[], -Variable,-,u8x8_font_victoriabold8_r,const uint8_t[], -Variable,-,u8x8_font_victoriabold8_u,const uint8_t[], -Variable,-,u8x8_font_victoriamedium8_n,const uint8_t[], -Variable,-,u8x8_font_victoriamedium8_r,const uint8_t[], -Variable,-,u8x8_font_victoriamedium8_u,const uint8_t[], Variable,+,usb_cdc_dual,FuriHalUsbInterface, Variable,+,usb_cdc_single,FuriHalUsbInterface, Variable,+,usb_hid,FuriHalUsbInterface, diff --git a/lib/SConscript b/lib/SConscript index ec5dfda1e5..8727746d81 100644 --- a/lib/SConscript +++ b/lib/SConscript @@ -44,7 +44,6 @@ env.Append( "variant", ) ), - File("u8g2/u8g2.h"), ], CPPDEFINES=[ '"M_MEMORY_FULL(x)=abort()"', From 1d11bc64a935270b7a2fac2c0df9fa2ef0bddcf9 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 22 May 2023 06:00:45 +0300 Subject: [PATCH 44/92] Update readme & changelog --- CHANGELOG.md | 49 +++++++++++-------------------------------------- ReadMe.md | 2 +- 2 files changed, 12 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a16fc8256a..5dc889d2fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,42 +1,15 @@ ### New changes -* **Warning! After installing, Desktop settings (Favoutite apps, PIN Code, AutoLock time..) will be resetted to default due to OFW changes, Please set your PIN code, Favourite apps again in Settings->Desktop** -* New way of changing device name -> **Now can be changed in Settings->Desktop** (by @xMasterX and @Willy-JL) -* Plugins: BadBT plugin (BT version of BadKB) [(by Willy-JL, ClaraCrazy, XFW contributors)](https://github.com/ClaraCrazy/Flipper-Xtreme/tree/dev/applications/main/bad_kb) -* Plugins: WiFi Marauder -> Added sniff pmkid on selected aps from 0.10.4 update (by @clipboard1) -* Plugins: SubGHz Bruteforcer -> Increase delay just a little bit to fix some cases when receiver will not get codes and decrease manual transmit delay -* Plugins: UART Terminal -> Fix crashes on plugin load with RX connected -* NFC: Mifare mini with SAK 0x89 support -* SubGHz: **CAME Atomo - Add manually support and custom buttons support** -* SubGHz: Fix crashes when deleting signals using right arrow button in `Read` mode -* SubGHz: Restore Rx indication after deletion after Memory is FULL (by @wosk | PR #464) -* SubGHz: **App refactoring** (OFW code ported + our code was refactored/cleaned up too) (by @gid9798 and @xMasterX | PR #461) -* SubGHz: Using scene manager functions in DecodeRAW (by @gid9798 | PR #462) -* SubGHz: Protocols and custom buttons refactoring (by @gid9798 | PR #465) -* SubGHz: Move `counter increase` setting out of debug, change max value -* GUI: Submenu locked elements (by @Willy-JL and @giacomoferretti) -* GUI: Text Input improvements, added cursor and ability to set minimal length (by @Willy-JL) -* BT API: Functions that allow to change bt mac address and device broadcasted name (by @Willy-JL and XFW contributors) -* Infrared: `External output` move out of debug and add power option for external modules -* Infrared: Updated universal remote assets (by @amec0e | PR #474) -* Extra pack: Some app fixes -* FBT: Fix vscode example config for debug builds - please run `./fbt vscode_dist` again if you had issues with debug builds size -* OFW PR 2316: NFC V support (by @g3gg0 & @nvx) -* OFW PR 2669: nfc: Fix MFUL tearing flags read (by @GMMan) -* OFW PR 2666: BadUSB: Add fr-FR-mac key layout (by @FelixLgr) -* OFW: api: added lib/nfc/protocols/nfc_util.h -* OFW: fix PIN retry count reset on reboot -* OFW: fbt: allow strings for fap_version field in app manifests -* OFW: Rpc: add desktop service. Desktop: refactor locking routine. **Now PIN lock is actually cannot be bypassed by reboot!** / **Desktop settings will be reset, please set your PIN and favourite apps again!** -* OFW: Part 2 of hooking C2 IPC -* OFW: ble: attempt to handle hardfaulted c2 -* OFW: Add Mfkey32 application -* OFW: Added DigitalSequence and PulseReader -* OFW: Debug: revert cortex debug to lxml and drop DWT **(reapply your VSCode launch.json from example folder)** -* OFW: furi_crash: added C2 status; added fw-version gdb command -* OFW: Removed STM32CubeWB module -* OFW: API version in UI -* OFW: ufbt: deploying sample ufbt automation for new apps; added `source "ufbt -s env"` for toolchain access -* OFW: Fix storage.py exist_dir logic +* SubGHz Remote: Full refactoring, app was re-made from scratch (by @gid9798) +* API: Cleanup, mini refactoring of some apps (+6k of free flash space) +* SubGHz: Various fixes (by @gid9798) +* SubGHz: Fix counter settings in debug +* SubGHz: Move dangerous_settings check (by @gid9798 | PR #475) +* Misc: Name changer code moved to proper place, load after system startup + extra checks +* Plugins: NMEA GPS UART - stability fix +* Plugins: Port XFW keyboard with extra symbols to WiFi Marauder instead of using UART Term keyboard (thanks to @Willy-JL) +* Plugins: Update WiFi Marauder [(by 0xchocolate)](https://github.com/0xchocolate/flipperzero-firmware-with-wifi-marauder-companion) +* OFW: fbt: Use union for old py (Fix builds if using older python versions) +* OFW PR 2682: USB HID report timeout (by nminaylov) #### [🎲 Download latest extra apps pack](https://github.com/xMasterX/all-the-plugins/archive/refs/heads/main.zip) diff --git a/ReadMe.md b/ReadMe.md index 596891d6ee..fe6c7fb34b 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -145,7 +145,7 @@ You can support us by using links or addresses below: - ESP32: WiFi Marauder companion plugin [(by 0xchocolate)](https://github.com/0xchocolate/flipperzero-firmware-with-wifi-marauder-companion) - Saving .pcap on flipper microSD [by tcpassos](https://github.com/tcpassos/flipperzero-firmware-with-wifi-marauder-companion) -> Only with custom marauder build (It is necessary to uncomment "#define WRITE_PACKETS_SERIAL" in configs.h (in marauder fw) and compile the firmware for the wifi board.) Or download precompiled build -> [Download esp32_marauder_ver_flipper_sd_serial.bin](https://github.com/justcallmekoko/ESP32Marauder/releases/latest) - NRF24: Sniffer & MouseJacker (with changes) [(by mothball187)](https://github.com/mothball187/flipperzero-nrf24/tree/main/mousejacker) - Simple Clock (timer by GMMan) [(original by CompaqDisc)](https://gist.github.com/CompaqDisc/4e329c501bd03c1e801849b81f48ea61) -- **Sub-GHz Remote** (UniversalRF Remix) [(by @darmiel & @xMasterX)](https://github.com/darmiel/flipper-playlist/tree/feat/unirf-protocols) (original by @ESurge) +- **Sub-GHz Remote** [(by @gid9798)](https://github.com/gid9798) - Spectrum Analyzer (with changes) [(by jolcese)](https://github.com/jolcese/flipperzero-firmware/tree/spectrum/applications/spectrum_analyzer) - [Ultra Narrow mode & scan channels non-consecutively](https://github.com/theY4Kman/flipperzero-firmware/commits?author=theY4Kman) - Metronome [(by panki27)](https://github.com/panki27/Metronome) - DTMF Dolphin [(by litui)](https://github.com/litui/dtmf_dolphin) From 451ba8da9f04a88f892e6caa6aba457ab25f5d31 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 22 May 2023 06:03:28 +0300 Subject: [PATCH 45/92] More API cleanup --- firmware/targets/f7/api_symbols.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 3313f3ecd8..cd79ebb239 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -2515,7 +2515,7 @@ Function,-,select,int,"int, fd_set*, fd_set*, fd_set*, timeval*" Function,-,serial_svc_is_started,_Bool, Function,-,serial_svc_notify_buffer_is_empty,void, Function,-,serial_svc_set_callbacks,void,"uint16_t, SerialServiceEventCallback, void*" -Function,+,serial_svc_set_rpc_status,void,SerialServiceRpcStatus +Function,-,serial_svc_set_rpc_status,void,SerialServiceRpcStatus Function,-,serial_svc_start,void, Function,-,serial_svc_stop,void, Function,-,serial_svc_update_tx,_Bool,"uint8_t*, uint16_t" From 544b6fea8a076cd218093bbb9f262147f8367874 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Mon, 22 May 2023 11:42:27 +0300 Subject: [PATCH 46/92] clock port --- applications/services/desktop/desktop.c | 58 +++++++++++++++++++++++ applications/services/desktop/desktop_i.h | 1 + 2 files changed, 59 insertions(+) diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 77999dfcc0..6d9db3b5de 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -48,6 +48,57 @@ static void desktop_dummy_mode_icon_draw_callback(Canvas* canvas, void* context) canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8); } +static void desktop_clock_draw_callback(Canvas* canvas, void* context) { + //UNUSED(context); + furi_assert(context); + furi_assert(canvas); + + Desktop* desktop = context; + // canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8); + + const char* s[4]; + + s[0] = "4"; + s[1] = "4"; + s[2] = "4"; + s[3] = "1"; + + canvas_set_font(canvas, FontPrimary); + + uint8_t new_w = ((strcmp(s[0], "1") == 0) ? 3 : 5) + //c1 + ((strcmp(s[1], "1") == 0) ? 3 : 5) + //c2 + ((strcmp(s[2], "1") == 0) ? 3 : 5) + //c3 + ((strcmp(s[3], "1") == 0) ? 3 : 5) + //c4 + 2 + 4; // ":" + 4 separators + + view_port_set_width(desktop->clock_viewport, new_w); + uint8_t x = new_w; + + uint8_t y = 8; + uint8_t offset_r; + + canvas_draw_str_aligned(canvas, x, y, AlignRight, AlignBottom, s[0]); + offset_r = (strcmp(s[0], "1") == 0) ? 3 : 5; + + canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, s[1]); + offset_r = (strcmp(s[1], "1") == 0) ? 3 : 5; + + canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y - 1, AlignRight, AlignBottom, ":"); + offset_r = 2; + + canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, s[2]); + offset_r = (strcmp(s[2], "1") == 0) ? 3 : 5; + + canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, s[3]); + offset_r = (strcmp(s[3], "1") == 0) ? 3 : 5; + + x -= (offset_r + 1); + + // canvas_set_font(canvas, FontSecondary); + + // canvas_draw_str_aligned(canvas, 14, y - 1, AlignRight, AlignBottom, ":"); +} + static void desktop_stealth_mode_icon_draw_callback(Canvas* canvas, void* context) { UNUSED(context); furi_assert(canvas); @@ -279,6 +330,13 @@ Desktop* desktop_alloc() { view_port_enabled_set(desktop->dummy_mode_icon_viewport, false); gui_add_view_port(desktop->gui, desktop->dummy_mode_icon_viewport, GuiLayerStatusBarLeft); + // Clock + desktop->clock_viewport = view_port_alloc(); + view_port_set_width(desktop->clock_viewport, 26); + view_port_draw_callback_set(desktop->clock_viewport, desktop_clock_draw_callback, desktop); + view_port_enabled_set(desktop->clock_viewport, true); + gui_add_view_port(desktop->gui, desktop->clock_viewport, GuiLayerStatusBarRight); + // Stealth mode icon desktop->stealth_mode_icon_viewport = view_port_alloc(); view_port_set_width(desktop->stealth_mode_icon_viewport, icon_get_width(&I_Muted_8x8)); diff --git a/applications/services/desktop/desktop_i.h b/applications/services/desktop/desktop_i.h index ede6bbcc31..1d9df7c858 100644 --- a/applications/services/desktop/desktop_i.h +++ b/applications/services/desktop/desktop_i.h @@ -59,6 +59,7 @@ struct Desktop { ViewPort* lock_icon_viewport; ViewPort* dummy_mode_icon_viewport; + ViewPort* clock_viewport; ViewPort* stealth_mode_icon_viewport; AnimationManager* animation_manager; From 5f1ac6e1b14595e8727497b9227ad239d60f2d86 Mon Sep 17 00:00:00 2001 From: Yukai Li Date: Mon, 22 May 2023 03:14:18 -0600 Subject: [PATCH 47/92] fbt: Fix tar uid overflow when packaging (#2689) * fbt: Fix tar uid overflow when packaging * Fix trailing spaces --- scripts/sconsdist.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/sconsdist.py b/scripts/sconsdist.py index d2d1d2f49c..4617811365 100644 --- a/scripts/sconsdist.py +++ b/scripts/sconsdist.py @@ -271,7 +271,13 @@ def bundle_update_package(self): self.note_dist_component( "update", "tgz", self.get_dist_path(bundle_tgz) ) - tar.add(bundle_dir, arcname=bundle_dir_name) + + # Strip uid and gid in case of overflow + def tar_filter(tarinfo): + tarinfo.uid = tarinfo.gid = 0 + return tarinfo + + tar.add(bundle_dir, arcname=bundle_dir_name, filter=tar_filter) return bundle_result From e40620fd108d63b03e07e3e0a1e4900727b0ed63 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Mon, 22 May 2023 22:45:16 +0300 Subject: [PATCH 48/92] clock --- applications/services/desktop/desktop.c | 72 +++++++++++++++++------ applications/services/desktop/desktop_i.h | 4 ++ 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 6d9db3b5de..050f6bcbdb 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -48,6 +48,16 @@ static void desktop_dummy_mode_icon_draw_callback(Canvas* canvas, void* context) canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8); } +static uint8_t desktop_clock_get_num_w(uint8_t num) { + if(num == 1) { + return 3; + } else { + return 5; + } +} + +static const char* digit[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; + static void desktop_clock_draw_callback(Canvas* canvas, void* context) { //UNUSED(context); furi_assert(context); @@ -56,19 +66,19 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) { Desktop* desktop = context; // canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8); - const char* s[4]; - - s[0] = "4"; - s[1] = "4"; - s[2] = "4"; - s[3] = "1"; + uint8_t d[4] = { + desktop->minute % 10, + desktop->minute / 10, + desktop->hour % 10, + desktop->hour / 10, + }; canvas_set_font(canvas, FontPrimary); - uint8_t new_w = ((strcmp(s[0], "1") == 0) ? 3 : 5) + //c1 - ((strcmp(s[1], "1") == 0) ? 3 : 5) + //c2 - ((strcmp(s[2], "1") == 0) ? 3 : 5) + //c3 - ((strcmp(s[3], "1") == 0) ? 3 : 5) + //c4 + uint8_t new_w = desktop_clock_get_num_w(d[0]) + //c1 + desktop_clock_get_num_w(d[1]) + //c2 + desktop_clock_get_num_w(d[2]) + //c3 + desktop_clock_get_num_w(d[3]) + //c4 2 + 4; // ":" + 4 separators view_port_set_width(desktop->clock_viewport, new_w); @@ -77,20 +87,20 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) { uint8_t y = 8; uint8_t offset_r; - canvas_draw_str_aligned(canvas, x, y, AlignRight, AlignBottom, s[0]); - offset_r = (strcmp(s[0], "1") == 0) ? 3 : 5; + canvas_draw_str_aligned(canvas, x, y, AlignRight, AlignBottom, digit[d[0]]); + offset_r = desktop_clock_get_num_w(d[0]); - canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, s[1]); - offset_r = (strcmp(s[1], "1") == 0) ? 3 : 5; + canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, digit[d[1]]); + offset_r = desktop_clock_get_num_w(d[1]); canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y - 1, AlignRight, AlignBottom, ":"); offset_r = 2; - canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, s[2]); - offset_r = (strcmp(s[2], "1") == 0) ? 3 : 5; + canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, digit[d[2]]); + offset_r = desktop_clock_get_num_w(d[2]); - canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, s[3]); - offset_r = (strcmp(s[3], "1") == 0) ? 3 : 5; + canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, digit[d[3]]); + offset_r = desktop_clock_get_num_w(d[3]); x -= (offset_r + 1); @@ -184,6 +194,20 @@ static void desktop_auto_lock_inhibit(Desktop* desktop) { } } +static void desktop_update_clock_timer_callback(void* context) { + furi_assert(context); + Desktop* desktop = context; + + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + + desktop->hour = curr_dt.hour; + desktop->minute = curr_dt.minute; + view_port_update(desktop->clock_viewport); + + // view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAutoLock); +} + void desktop_lock(Desktop* desktop) { furi_hal_rtc_set_flag(FuriHalRtcFlagLock); @@ -366,6 +390,17 @@ Desktop* desktop_alloc() { desktop->auto_lock_timer = furi_timer_alloc(desktop_auto_lock_timer_callback, FuriTimerTypeOnce, desktop); + desktop->update_clock_timer = + furi_timer_alloc(desktop_update_clock_timer_callback, FuriTimerTypePeriodic, desktop); + + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + + desktop->hour = curr_dt.hour; + desktop->minute = curr_dt.minute; + + furi_timer_start(desktop->update_clock_timer, furi_ms_to_ticks(1000)); + furi_record_create(RECORD_DESKTOP, desktop); return desktop; @@ -419,6 +454,7 @@ void desktop_free(Desktop* desktop) { furi_record_close("menu"); furi_timer_free(desktop->auto_lock_timer); + furi_timer_free(desktop->update_clock_timer); free(desktop); } diff --git a/applications/services/desktop/desktop_i.h b/applications/services/desktop/desktop_i.h index 1d9df7c858..0fac0f34cd 100644 --- a/applications/services/desktop/desktop_i.h +++ b/applications/services/desktop/desktop_i.h @@ -71,6 +71,10 @@ struct Desktop { FuriPubSub* input_events_pubsub; FuriPubSubSubscription* input_events_subscription; FuriTimer* auto_lock_timer; + FuriTimer* update_clock_timer; + + uint8_t hour; + uint8_t minute; bool in_transition; }; From a821a2fcc0eaa72a96f2a48c0424287e7f688e06 Mon Sep 17 00:00:00 2001 From: hedger Date: Tue, 23 May 2023 14:51:21 +0400 Subject: [PATCH 49/92] [FL-3328] Removed user-specific data from tar artifacts (#2691) --- scripts/sconsdist.py | 2 ++ scripts/update.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/scripts/sconsdist.py b/scripts/sconsdist.py index 4617811365..23f9526a0b 100644 --- a/scripts/sconsdist.py +++ b/scripts/sconsdist.py @@ -275,6 +275,8 @@ def bundle_update_package(self): # Strip uid and gid in case of overflow def tar_filter(tarinfo): tarinfo.uid = tarinfo.gid = 0 + tarinfo.mtime = 0 + tarinfo.uname = tarinfo.gname = "furippa" return tarinfo tar.add(bundle_dir, arcname=bundle_dir_name, filter=tar_filter) diff --git a/scripts/update.py b/scripts/update.py index 0f3ee6ea8b..9f0d95d94e 100755 --- a/scripts/update.py +++ b/scripts/update.py @@ -211,6 +211,9 @@ def _tar_filter(self, tarinfo: tarfile.TarInfo): f"Cannot package resource: name '{tarinfo.name}' too long" ) raise ValueError("Resource name too long") + tarinfo.gid = tarinfo.uid = 0 + tarinfo.mtime = 0 + tarinfo.uname = tarinfo.gname = "furippa" return tarinfo def package_resources(self, srcdir: str, dst_name: str): From c82ed71b6f77a66e939879e7596cf8c3563bae5a Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Tue, 23 May 2023 16:41:57 +0300 Subject: [PATCH 50/92] cleanup --- applications/services/desktop/desktop.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 050f6bcbdb..31e53f3f27 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -51,6 +51,8 @@ static void desktop_dummy_mode_icon_draw_callback(Canvas* canvas, void* context) static uint8_t desktop_clock_get_num_w(uint8_t num) { if(num == 1) { return 3; + } else if(num == 4) { + return 6; } else { return 5; } @@ -59,12 +61,10 @@ static uint8_t desktop_clock_get_num_w(uint8_t num) { static const char* digit[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; static void desktop_clock_draw_callback(Canvas* canvas, void* context) { - //UNUSED(context); furi_assert(context); furi_assert(canvas); Desktop* desktop = context; - // canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8); uint8_t d[4] = { desktop->minute % 10, @@ -81,7 +81,8 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) { desktop_clock_get_num_w(d[3]) + //c4 2 + 4; // ":" + 4 separators - view_port_set_width(desktop->clock_viewport, new_w); + view_port_set_width(desktop->clock_viewport, new_w - 1); + uint8_t x = new_w; uint8_t y = 8; @@ -100,13 +101,6 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) { offset_r = desktop_clock_get_num_w(d[2]); canvas_draw_str_aligned(canvas, x -= (offset_r + 1), y, AlignRight, AlignBottom, digit[d[3]]); - offset_r = desktop_clock_get_num_w(d[3]); - - x -= (offset_r + 1); - - // canvas_set_font(canvas, FontSecondary); - - // canvas_draw_str_aligned(canvas, 14, y - 1, AlignRight, AlignBottom, ":"); } static void desktop_stealth_mode_icon_draw_callback(Canvas* canvas, void* context) { @@ -200,10 +194,11 @@ static void desktop_update_clock_timer_callback(void* context) { FuriHalRtcDateTime curr_dt; furi_hal_rtc_get_datetime(&curr_dt); - - desktop->hour = curr_dt.hour; - desktop->minute = curr_dt.minute; - view_port_update(desktop->clock_viewport); + if(desktop->minute != curr_dt.minute) { + desktop->hour = curr_dt.hour; + desktop->minute = curr_dt.minute; + view_port_update(desktop->clock_viewport); + } // view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAutoLock); } @@ -356,7 +351,7 @@ Desktop* desktop_alloc() { // Clock desktop->clock_viewport = view_port_alloc(); - view_port_set_width(desktop->clock_viewport, 26); + view_port_set_width(desktop->clock_viewport, 25); view_port_draw_callback_set(desktop->clock_viewport, desktop_clock_draw_callback, desktop); view_port_enabled_set(desktop->clock_viewport, true); gui_add_view_port(desktop->gui, desktop->clock_viewport, GuiLayerStatusBarRight); From 711f0fef405fefc51d08fdafd942423a6aba9bcc Mon Sep 17 00:00:00 2001 From: Sergey Gavrilov Date: Tue, 23 May 2023 07:59:32 -0700 Subject: [PATCH 51/92] [FL-3327] Storage: common_rename is now POSIX compliant (#2693) * Storage: common_rename is now POSIX compliant * storage: check for success on storage_common_remove in file rename --------- Co-authored-by: hedger --- applications/services/storage/storage.h | 2 +- applications/services/storage/storage_external_api.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/applications/services/storage/storage.h b/applications/services/storage/storage.h index a1267575fb..dccf29592c 100644 --- a/applications/services/storage/storage.h +++ b/applications/services/storage/storage.h @@ -226,7 +226,7 @@ FS_Error storage_common_stat(Storage* storage, const char* path, FileInfo* filei */ FS_Error storage_common_remove(Storage* storage, const char* path); -/** Renames file/directory, file/directory must not be open +/** Renames file/directory, file/directory must not be open. Will overwrite existing file. * @param app pointer to the api * @param old_path old path * @param new_path new path diff --git a/applications/services/storage/storage_external_api.c b/applications/services/storage/storage_external_api.c index bf474bc9d0..549397c87d 100644 --- a/applications/services/storage/storage_external_api.c +++ b/applications/services/storage/storage_external_api.c @@ -422,7 +422,16 @@ FS_Error storage_common_remove(Storage* storage, const char* path) { } FS_Error storage_common_rename(Storage* storage, const char* old_path, const char* new_path) { - FS_Error error = storage_common_copy(storage, old_path, new_path); + FS_Error error; + + if(storage_file_exists(storage, new_path)) { + error = storage_common_remove(storage, new_path); + if(error != FSE_OK) { + return error; + } + } + + error = storage_common_copy(storage, old_path, new_path); if(error == FSE_OK) { if(!storage_simply_remove_recursive(storage, old_path)) { error = FSE_INTERNAL; From 3217f286f03da119398586daf94c0723d28b872a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Wed, 24 May 2023 00:17:12 +0900 Subject: [PATCH 52/92] Services: remove deallocator for persistent services (#2692) Co-authored-by: hedger --- applications/services/desktop/desktop.c | 55 +------------------ applications/services/dolphin/dolphin.c | 11 +--- applications/services/dolphin/dolphin_i.h | 2 - .../services/power/power_service/power.c | 26 +-------- 4 files changed, 4 insertions(+), 90 deletions(-) diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 77999dfcc0..36589aed4c 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -313,58 +313,6 @@ Desktop* desktop_alloc() { return desktop; } -void desktop_free(Desktop* desktop) { - furi_assert(desktop); - furi_check(furi_record_destroy(RECORD_DESKTOP)); - - furi_pubsub_unsubscribe( - loader_get_pubsub(desktop->loader), desktop->app_start_stop_subscription); - - if(desktop->input_events_subscription) { - furi_pubsub_unsubscribe(desktop->input_events_pubsub, desktop->input_events_subscription); - desktop->input_events_subscription = NULL; - } - - desktop->loader = NULL; - desktop->input_events_pubsub = NULL; - furi_record_close(RECORD_LOADER); - furi_record_close(RECORD_NOTIFICATION); - furi_record_close(RECORD_INPUT_EVENTS); - - view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdMain); - view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdLockMenu); - view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdLocked); - view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdDebug); - view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdHwMismatch); - view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdPinInput); - view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdPinTimeout); - - view_dispatcher_free(desktop->view_dispatcher); - scene_manager_free(desktop->scene_manager); - - animation_manager_free(desktop->animation_manager); - view_stack_free(desktop->main_view_stack); - desktop_main_free(desktop->main_view); - view_stack_free(desktop->locked_view_stack); - desktop_view_locked_free(desktop->locked_view); - desktop_lock_menu_free(desktop->lock_menu); - desktop_view_locked_free(desktop->locked_view); - desktop_debug_free(desktop->debug_view); - popup_free(desktop->hw_mismatch_popup); - desktop_view_pin_timeout_free(desktop->pin_timeout_view); - - furi_record_close(RECORD_GUI); - desktop->gui = NULL; - - furi_thread_free(desktop->scene_thread); - - furi_record_close("menu"); - - furi_timer_free(desktop->auto_lock_timer); - - free(desktop); -} - static bool desktop_check_file_flag(const char* flag_path) { Storage* storage = furi_record_open(RECORD_STORAGE); bool exists = storage_common_stat(storage, flag_path, NULL) == FSE_OK; @@ -427,7 +375,8 @@ int32_t desktop_srv(void* p) { } view_dispatcher_run(desktop->view_dispatcher); - desktop_free(desktop); + + furi_crash("That was unexpected"); return 0; } diff --git a/applications/services/dolphin/dolphin.c b/applications/services/dolphin/dolphin.c index dd8b7105f0..93a9b3095b 100644 --- a/applications/services/dolphin/dolphin.c +++ b/applications/services/dolphin/dolphin.c @@ -89,15 +89,6 @@ Dolphin* dolphin_alloc() { return dolphin; } -void dolphin_free(Dolphin* dolphin) { - furi_assert(dolphin); - - dolphin_state_free(dolphin->state); - furi_message_queue_free(dolphin->event_queue); - - free(dolphin); -} - void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event) { furi_assert(dolphin); furi_assert(event); @@ -204,7 +195,7 @@ int32_t dolphin_srv(void* p) { } } - dolphin_free(dolphin); + furi_crash("That was unexpected"); return 0; } diff --git a/applications/services/dolphin/dolphin_i.h b/applications/services/dolphin/dolphin_i.h index 4bb0df08ee..ceeff1e1a9 100644 --- a/applications/services/dolphin/dolphin_i.h +++ b/applications/services/dolphin/dolphin_i.h @@ -37,8 +37,6 @@ struct Dolphin { Dolphin* dolphin_alloc(); -void dolphin_free(Dolphin* dolphin); - void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event); void dolphin_event_send_wait(Dolphin* dolphin, DolphinEvent* event); diff --git a/applications/services/power/power_service/power.c b/applications/services/power/power_service/power.c index 56dbd0f87c..72dc8f3f1e 100644 --- a/applications/services/power/power_service/power.c +++ b/applications/services/power/power_service/power.c @@ -85,30 +85,6 @@ Power* power_alloc() { return power; } -void power_free(Power* power) { - furi_assert(power); - - // Gui - view_dispatcher_remove_view(power->view_dispatcher, PowerViewOff); - power_off_free(power->power_off); - view_dispatcher_remove_view(power->view_dispatcher, PowerViewUnplugUsb); - power_unplug_usb_free(power->power_unplug_usb); - - view_port_free(power->battery_view_port); - - // State - furi_mutex_free(power->api_mtx); - - // FuriPubSub - furi_pubsub_free(power->event_pubsub); - - // Records - furi_record_close(RECORD_NOTIFICATION); - furi_record_close(RECORD_GUI); - - free(power); -} - static void power_check_charging_state(Power* power) { if(furi_hal_power_is_charging()) { if((power->info.charge == 100) || (furi_hal_power_is_charging_done())) { @@ -252,7 +228,7 @@ int32_t power_srv(void* p) { furi_delay_ms(1000); } - power_free(power); + furi_crash("That was unexpected"); return 0; } From 1d5a4240b9dc63508d12746bafd8ab0a68b34a00 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Tue, 23 May 2023 22:47:15 +0300 Subject: [PATCH 53/92] Clock: some improvements --- applications/services/desktop/desktop.c | 62 +++++++++++++++---- applications/services/desktop/desktop_i.h | 3 +- .../services/desktop/desktop_settings.h | 1 + applications/services/gui/gui.c | 17 +++++ applications/services/gui/gui.h | 2 + .../scenes/desktop_settings_scene_start.c | 34 +++++++++- firmware/targets/f7/api_symbols.csv | 1 + 7 files changed, 105 insertions(+), 15 deletions(-) diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 31e53f3f27..c25af0da5a 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "animations/animation_manager.h" #include "desktop/scenes/desktop_scene.h" @@ -48,6 +49,21 @@ static void desktop_dummy_mode_icon_draw_callback(Canvas* canvas, void* context) canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8); } +static void desktop_togle_clock_view(Desktop* desktop, bool is_enabled) { + furi_assert(desktop); + + // clock type upd after 1 minute + desktop->clock_type = (locale_get_time_format() == LocaleTimeFormat24h); + + if(is_enabled) { // && !furi_timer_is_running(desktop->update_clock_timer)) { + furi_timer_start(desktop->update_clock_timer, furi_ms_to_ticks(1000)); + } else if(!is_enabled) { //&& furi_timer_is_running(desktop->update_clock_timer)) { + furi_timer_stop(desktop->update_clock_timer); + } + + view_port_enabled_set(desktop->clock_viewport, is_enabled); +} + static uint8_t desktop_clock_get_num_w(uint8_t num) { if(num == 1) { return 3; @@ -81,7 +97,8 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) { desktop_clock_get_num_w(d[3]) + //c4 2 + 4; // ":" + 4 separators - view_port_set_width(desktop->clock_viewport, new_w - 1); + // further away from the battery charge indicator, if the smallest minute is 1 + view_port_set_width(desktop->clock_viewport, new_w - !(d[0] == 1)); uint8_t x = new_w; @@ -123,6 +140,9 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) { // TODO: Implement a message mechanism for loading settings and (optionally) // locking and unlocking DESKTOP_SETTINGS_LOAD(&desktop->settings); + + desktop_togle_clock_view(desktop, desktop->settings.display_clock); + desktop_auto_lock_arm(desktop); return true; case DesktopGlobalAutoLock: @@ -192,15 +212,25 @@ static void desktop_update_clock_timer_callback(void* context) { furi_assert(context); Desktop* desktop = context; - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - if(desktop->minute != curr_dt.minute) { - desktop->hour = curr_dt.hour; - desktop->minute = curr_dt.minute; - view_port_update(desktop->clock_viewport); - } + if(gui_get_count_of_enabled_view_port_in_layer(desktop->gui, GuiLayerStatusBarLeft) < 6) { + FuriHalRtcDateTime curr_dt; + furi_hal_rtc_get_datetime(&curr_dt); + + if(desktop->minute != curr_dt.minute) { + if(desktop->clock_type) { + desktop->hour = curr_dt.hour; + } else { + desktop->hour = (curr_dt.hour > 12) ? curr_dt.hour - 12 : + ((curr_dt.hour == 0) ? 12 : curr_dt.hour); + } + desktop->minute = curr_dt.minute; + view_port_update(desktop->clock_viewport); + } - // view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAutoLock); + view_port_enabled_set(desktop->clock_viewport, true); + } else { + view_port_enabled_set(desktop->clock_viewport, false); + } } void desktop_lock(Desktop* desktop) { @@ -353,7 +383,7 @@ Desktop* desktop_alloc() { desktop->clock_viewport = view_port_alloc(); view_port_set_width(desktop->clock_viewport, 25); view_port_draw_callback_set(desktop->clock_viewport, desktop_clock_draw_callback, desktop); - view_port_enabled_set(desktop->clock_viewport, true); + view_port_enabled_set(desktop->clock_viewport, false); gui_add_view_port(desktop->gui, desktop->clock_viewport, GuiLayerStatusBarRight); // Stealth mode icon @@ -391,11 +421,14 @@ Desktop* desktop_alloc() { FuriHalRtcDateTime curr_dt; furi_hal_rtc_get_datetime(&curr_dt); - desktop->hour = curr_dt.hour; + if(desktop->clock_type) { + desktop->hour = curr_dt.hour; + } else { + desktop->hour = (curr_dt.hour > 12) ? curr_dt.hour - 12 : + ((curr_dt.hour == 0) ? 12 : curr_dt.hour); + } desktop->minute = curr_dt.minute; - furi_timer_start(desktop->update_clock_timer, furi_ms_to_ticks(1000)); - furi_record_create(RECORD_DESKTOP, desktop); return desktop; @@ -489,6 +522,9 @@ int32_t desktop_srv(void* p) { } view_port_enabled_set(desktop->dummy_mode_icon_viewport, desktop->settings.dummy_mode); + + desktop_togle_clock_view(desktop, desktop->settings.display_clock); + desktop_main_set_dummy_mode_state(desktop->main_view, desktop->settings.dummy_mode); animation_manager_set_dummy_mode_state( desktop->animation_manager, desktop->settings.dummy_mode); diff --git a/applications/services/desktop/desktop_i.h b/applications/services/desktop/desktop_i.h index 0fac0f34cd..2d033c1964 100644 --- a/applications/services/desktop/desktop_i.h +++ b/applications/services/desktop/desktop_i.h @@ -75,8 +75,9 @@ struct Desktop { uint8_t hour; uint8_t minute; + bool clock_type : 1; // true - 24h false - 12h - bool in_transition; + bool in_transition : 1; }; Desktop* desktop_alloc(); diff --git a/applications/services/desktop/desktop_settings.h b/applications/services/desktop/desktop_settings.h index e750c696c3..49291b3710 100644 --- a/applications/services/desktop/desktop_settings.h +++ b/applications/services/desktop/desktop_settings.h @@ -63,4 +63,5 @@ typedef struct { uint32_t auto_lock_delay_ms; uint8_t displayBatteryPercentage; uint8_t dummy_mode; + uint8_t display_clock; } DesktopSettings; diff --git a/applications/services/gui/gui.c b/applications/services/gui/gui.c index 392011620a..87cc962cad 100644 --- a/applications/services/gui/gui.c +++ b/applications/services/gui/gui.c @@ -17,6 +17,23 @@ ViewPort* gui_view_port_find_enabled(ViewPortArray_t array) { return NULL; } +uint8_t gui_get_count_of_enabled_view_port_in_layer(Gui* gui, GuiLayer layer) { + furi_assert(gui); + furi_check(layer < GuiLayerMAX); + uint8_t ret = 0; + + ViewPortArray_it_t it; + ViewPortArray_it_last(it, gui->layers[layer]); + while(!ViewPortArray_end_p(it)) { + ViewPort* view_port = *ViewPortArray_ref(it); + if(view_port_is_enabled(view_port)) { + ret++; + } + ViewPortArray_previous(it); + } + return ret; +} + void gui_update(Gui* gui) { furi_assert(gui); if(!gui->direct_draw) furi_thread_flags_set(gui->thread_id, GUI_THREAD_FLAG_DRAW); diff --git a/applications/services/gui/gui.h b/applications/services/gui/gui.h index 1b5987edac..a59a4ff6a4 100644 --- a/applications/services/gui/gui.h +++ b/applications/services/gui/gui.h @@ -132,6 +132,8 @@ Canvas* gui_direct_draw_acquire(Gui* gui); */ void gui_direct_draw_release(Gui* gui); +uint8_t gui_get_count_of_enabled_view_port_in_layer(Gui* gui, GuiLayer layer); + #ifdef __cplusplus } #endif diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c index 9d63f66287..b9233a0fa7 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c @@ -11,7 +11,8 @@ #define SCENE_EVENT_SELECT_PIN_SETUP 3 #define SCENE_EVENT_SELECT_AUTO_LOCK_DELAY 4 #define SCENE_EVENT_SELECT_BATTERY_DISPLAY 5 -#define SCENE_EVENT_SELECT_CHANGE_NAME 6 +#define SCENE_EVENT_SELECT_CLOCK_DISPLAY 6 +#define SCENE_EVENT_SELECT_CHANGE_NAME 7 #define AUTO_LOCK_DELAY_COUNT 9 const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = { @@ -29,6 +30,14 @@ const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = { const uint32_t auto_lock_delay_value[AUTO_LOCK_DELAY_COUNT] = {0, 10000, 15000, 30000, 60000, 90000, 120000, 300000, 600000}; +#define CLOCK_ENABLE_COUNT 2 +const char* const clock_enable_text[CLOCK_ENABLE_COUNT] = { + "OFF", + "ON", +}; + +const uint32_t clock_enable_value[CLOCK_ENABLE_COUNT] = {0, 1}; + #define BATTERY_VIEW_COUNT 6 const char* const battery_view_count_text[BATTERY_VIEW_COUNT] = @@ -55,6 +64,14 @@ static void desktop_settings_scene_start_battery_view_changed(VariableItem* item app->settings.displayBatteryPercentage = index; } +static void desktop_settings_scene_start_clock_enable_changed(VariableItem* item) { + DesktopSettingsApp* app = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + + variable_item_set_current_value_text(item, clock_enable_text[index]); + app->settings.display_clock = index; +} + static void desktop_settings_scene_start_auto_lock_delay_changed(VariableItem* item) { DesktopSettingsApp* app = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); @@ -106,6 +123,18 @@ void desktop_settings_scene_start_on_enter(void* context) { variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, battery_view_count_text[value_index]); + item = variable_item_list_add( + variable_item_list, + "Clock on desktop", + CLOCK_ENABLE_COUNT, + desktop_settings_scene_start_clock_enable_changed, // + app); + + value_index = + value_index_uint32(app->settings.display_clock, clock_enable_value, CLOCK_ENABLE_COUNT); + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, clock_enable_text[value_index]); + variable_item_list_add(variable_item_list, "Change Flipper Name", 0, NULL, app); view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewVarItemList); @@ -142,6 +171,9 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even case SCENE_EVENT_SELECT_BATTERY_DISPLAY: consumed = true; break; + case SCENE_EVENT_SELECT_CLOCK_DISPLAY: + consumed = true; + break; case SCENE_EVENT_SELECT_CHANGE_NAME: scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneChangeName); consumed = true; diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index cd79ebb239..2f9cf5314d 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1658,6 +1658,7 @@ Function,+,gui_add_framebuffer_callback,void,"Gui*, GuiCanvasCommitCallback, voi Function,+,gui_add_view_port,void,"Gui*, ViewPort*, GuiLayer" Function,+,gui_direct_draw_acquire,Canvas*,Gui* Function,+,gui_direct_draw_release,void,Gui* +Function,-,gui_get_count_of_enabled_view_port_in_layer,uint8_t,"Gui*, GuiLayer" Function,+,gui_get_framebuffer_size,size_t,const Gui* Function,+,gui_remove_framebuffer_callback,void,"Gui*, GuiCanvasCommitCallback, void*" Function,+,gui_remove_view_port,void,"Gui*, ViewPort*" From bce12a40486ffc184126d50e16145668000fad9a Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 24 May 2023 07:24:01 +0300 Subject: [PATCH 54/92] Update GPS UART --- .../external/gps_nmea_uart/gps_uart.c | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/applications/external/gps_nmea_uart/gps_uart.c b/applications/external/gps_nmea_uart/gps_uart.c index ada8f04f91..d44cf22eff 100644 --- a/applications/external/gps_nmea_uart/gps_uart.c +++ b/applications/external/gps_nmea_uart/gps_uart.c @@ -66,6 +66,19 @@ static void gps_uart_parse_nmea(GpsUart* gps_uart, char* line) { } } break; + case MINMEA_SENTENCE_GLL: { + struct minmea_sentence_gll frame; + if(minmea_parse_gll(&frame, line)) { + gps_uart->status.latitude = minmea_tocoord(&frame.latitude); + gps_uart->status.longitude = minmea_tocoord(&frame.longitude); + gps_uart->status.time_hours = frame.time.hours; + gps_uart->status.time_minutes = frame.time.minutes; + gps_uart->status.time_seconds = frame.time.seconds; + + notification_message_block(gps_uart->notifications, &sequence_blink_red_10); + } + } break; + default: break; } @@ -88,35 +101,53 @@ static int32_t gps_uart_worker(void* context) { if(events & WorkerEvtRxDone) { size_t len = 0; do { + // receive serial bytes into rx_buf, starting at rx_offset from the start of the buffer + // the maximum we can receive is RX_BUF_SIZE - 1 - rx_offset len = furi_stream_buffer_receive( gps_uart->rx_stream, gps_uart->rx_buf + rx_offset, RX_BUF_SIZE - 1 - rx_offset, 0); if(len > 0) { + // increase rx_offset by the number of bytes received, and null-terminate rx_buf rx_offset += len; gps_uart->rx_buf[rx_offset] = '\0'; + // look for strings ending in newlines, starting at the start of rx_buf char* line_current = (char*)gps_uart->rx_buf; while(1) { + // skip null characters while(*line_current == '\0' && line_current < (char*)gps_uart->rx_buf + rx_offset - 1) { line_current++; } + // find the next newline char* newline = strchr(line_current, '\n'); - if(newline) { + if(newline) // newline found + { + // put a null terminator in place of the newline, to delimit the line string *newline = '\0'; + + // attempt to parse the line as a NMEA sentence gps_uart_parse_nmea(gps_uart, line_current); + + // move the cursor to the character after the newline line_current = newline + 1; - } else { - if(line_current > (char*)gps_uart->rx_buf) { + } else // no more newlines found + { + if(line_current > + (char*)gps_uart->rx_buf) // at least one line was found + { + // clear parsed lines, and move any leftover bytes to the start of rx_buf rx_offset = 0; - while(*line_current) { + while( + *line_current) // stop when the original rx_offset terminator is reached + { gps_uart->rx_buf[rx_offset++] = *(line_current++); } } - break; + break; // go back to receiving bytes from the serial stream } } } From b12fc114c709c32924a8e5fcd0133f095d975e65 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 24 May 2023 07:42:03 +0300 Subject: [PATCH 55/92] Update WiFi Marauder plugin Added PR by justcallmekoko https://github.com/justcallmekoko/flipperzero-firmware-with-wifi-marauder-companion --- .../wifi_marauder_companion/scenes/wifi_marauder_scene_start.c | 1 + .../external/wifi_marauder_companion/wifi_marauder_app.h | 2 +- .../external/wifi_marauder_companion/wifi_marauder_app_i.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c b/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c index 28a3ed2a93..b2bd39d3e3 100644 --- a/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c +++ b/applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c @@ -97,6 +97,7 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = { NO_ARGS, FOCUS_CONSOLE_END, SHOW_STOPSCAN_TIP}, + {"Signal Monitor", {""}, 1, {"sigmon"}, NO_ARGS, FOCUS_CONSOLE_END, SHOW_STOPSCAN_TIP}, {"Channel", {"get", "set"}, 2, diff --git a/applications/external/wifi_marauder_companion/wifi_marauder_app.h b/applications/external/wifi_marauder_companion/wifi_marauder_app.h index 7e38560592..5457f89d84 100644 --- a/applications/external/wifi_marauder_companion/wifi_marauder_app.h +++ b/applications/external/wifi_marauder_companion/wifi_marauder_app.h @@ -4,7 +4,7 @@ extern "C" { #endif -#define WIFI_MARAUDER_APP_VERSION "v0.3.6" +#define WIFI_MARAUDER_APP_VERSION "v0.3.7" typedef struct WifiMarauderApp WifiMarauderApp; diff --git a/applications/external/wifi_marauder_companion/wifi_marauder_app_i.h b/applications/external/wifi_marauder_companion/wifi_marauder_app_i.h index 45e1e59207..2a16522bb3 100644 --- a/applications/external/wifi_marauder_companion/wifi_marauder_app_i.h +++ b/applications/external/wifi_marauder_companion/wifi_marauder_app_i.h @@ -26,7 +26,7 @@ #include #include -#define NUM_MENU_ITEMS (17) +#define NUM_MENU_ITEMS (18) #define WIFI_MARAUDER_TEXT_BOX_STORE_SIZE (4096) #define WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE (512) From 5c234c21069635fb00f8738a6cda0bba683e52c6 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 24 May 2023 07:48:33 +0300 Subject: [PATCH 56/92] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dc889d2fe..23e815ba98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,12 @@ * Misc: Name changer code moved to proper place, load after system startup + extra checks * Plugins: NMEA GPS UART - stability fix * Plugins: Port XFW keyboard with extra symbols to WiFi Marauder instead of using UART Term keyboard (thanks to @Willy-JL) +* Plugins: Update NMEA GPS UART [(by ezod)](https://github.com/ezod/flipperzero-gps) * Plugins: Update WiFi Marauder [(by 0xchocolate)](https://github.com/0xchocolate/flipperzero-firmware-with-wifi-marauder-companion) +* OFW: Services: remove deallocator for persistent services +* OFW: Storage: common_rename is now POSIX compliant +* OFW: Removed user-specific data from tar artifacts +* OFW: fbt: Fix tar uid overflow when packaging * OFW: fbt: Use union for old py (Fix builds if using older python versions) * OFW PR 2682: USB HID report timeout (by nminaylov) From 977c9e706e189333665ceadfdda1bd81baafdda7 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 24 May 2023 07:50:13 +0300 Subject: [PATCH 57/92] Fix typos --- applications/services/desktop/desktop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 33a99b07e0..ebc13ec9d6 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -49,7 +49,7 @@ static void desktop_dummy_mode_icon_draw_callback(Canvas* canvas, void* context) canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8); } -static void desktop_togle_clock_view(Desktop* desktop, bool is_enabled) { +static void desktop_toggle_clock_view(Desktop* desktop, bool is_enabled) { furi_assert(desktop); // clock type upd after 1 minute @@ -141,7 +141,7 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) { // locking and unlocking DESKTOP_SETTINGS_LOAD(&desktop->settings); - desktop_togle_clock_view(desktop, desktop->settings.display_clock); + desktop_toggle_clock_view(desktop, desktop->settings.display_clock); desktop_auto_lock_arm(desktop); return true; @@ -470,7 +470,7 @@ int32_t desktop_srv(void* p) { view_port_enabled_set(desktop->dummy_mode_icon_viewport, desktop->settings.dummy_mode); - desktop_togle_clock_view(desktop, desktop->settings.display_clock); + desktop_toggle_clock_view(desktop, desktop->settings.display_clock); desktop_main_set_dummy_mode_state(desktop->main_view, desktop->settings.dummy_mode); animation_manager_set_dummy_mode_state( From 035bb57c56bdcceaf8f1d78b570d59220d2eb8fe Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 24 May 2023 07:50:45 +0300 Subject: [PATCH 58/92] bump version!!! --- applications/services/desktop/desktop_settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/services/desktop/desktop_settings.h b/applications/services/desktop/desktop_settings.h index 49291b3710..fb63f26f5f 100644 --- a/applications/services/desktop/desktop_settings.h +++ b/applications/services/desktop/desktop_settings.h @@ -8,7 +8,7 @@ #include #include -#define DESKTOP_SETTINGS_VER (9) +#define DESKTOP_SETTINGS_VER (10) #define DESKTOP_SETTINGS_PATH INT_PATH(DESKTOP_SETTINGS_FILE_NAME) #define DESKTOP_SETTINGS_MAGIC (0x17) From d83d898cdc206b920b7b12d1a4937751f296f0ea Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 24 May 2023 08:26:17 +0300 Subject: [PATCH 59/92] Rename --- .../desktop_settings/scenes/desktop_settings_scene_start.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c index b9233a0fa7..43e86cdc69 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c @@ -125,7 +125,7 @@ void desktop_settings_scene_start_on_enter(void* context) { item = variable_item_list_add( variable_item_list, - "Clock on desktop", + "Show Clock", CLOCK_ENABLE_COUNT, desktop_settings_scene_start_clock_enable_changed, // app); From 88f0b635774afe76f15bb72a469e22d4449d7e35 Mon Sep 17 00:00:00 2001 From: Sergey Gavrilov Date: Thu, 25 May 2023 06:44:32 -0700 Subject: [PATCH 60/92] Storage, common_rename: check that old path is exists (#2698) * Storage, common_rename: check that old path is exists * Storage, common_rename: return correct status --- .../services/storage/storage_external_api.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/applications/services/storage/storage_external_api.c b/applications/services/storage/storage_external_api.c index 549397c87d..5fcaa59216 100644 --- a/applications/services/storage/storage_external_api.c +++ b/applications/services/storage/storage_external_api.c @@ -424,19 +424,25 @@ FS_Error storage_common_remove(Storage* storage, const char* path) { FS_Error storage_common_rename(Storage* storage, const char* old_path, const char* new_path) { FS_Error error; - if(storage_file_exists(storage, new_path)) { - error = storage_common_remove(storage, new_path); + do { + if(!storage_common_exists(storage, old_path)) { + error = FSE_INVALID_NAME; + break; + } + + if(storage_file_exists(storage, new_path)) { + storage_common_remove(storage, new_path); + } + + error = storage_common_copy(storage, old_path, new_path); if(error != FSE_OK) { - return error; + break; } - } - error = storage_common_copy(storage, old_path, new_path); - if(error == FSE_OK) { if(!storage_simply_remove_recursive(storage, old_path)) { error = FSE_INTERNAL; } - } + } while(false); return error; } From 080324f7e0b28283fd4da5b24b1efb41a0c9af0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Thu, 25 May 2023 23:22:31 +0900 Subject: [PATCH 61/92] [FL-3315] Desktop,Rpc: desktop status subscription (#2696) * Desktop,Rpc: desktop status subscription * Desktop,RPC: properly handle unsubscribe Co-authored-by: Sergey Gavrilov --- applications/services/desktop/desktop.c | 13 +++++ applications/services/desktop/desktop.h | 8 +++ applications/services/desktop/desktop_i.h | 2 + applications/services/rpc/rpc_desktop.c | 64 +++++++++++++++++++++++ assets/protobuf | 2 +- 5 files changed, 88 insertions(+), 1 deletion(-) diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 36589aed4c..e1da649408 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -147,6 +147,9 @@ void desktop_lock(Desktop* desktop) { desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER); scene_manager_next_scene(desktop->scene_manager, DesktopSceneLocked); notification_message(desktop->notification, &sequence_display_backlight_off_delay_1000); + + DesktopStatus status = {.locked = true}; + furi_pubsub_publish(desktop->status_pubsub, &status); } void desktop_unlock(Desktop* desktop) { @@ -165,6 +168,9 @@ void desktop_unlock(Desktop* desktop) { cli_session_open(cli, &cli_vcp); furi_record_close(RECORD_CLI); } + + DesktopStatus status = {.locked = false}; + furi_pubsub_publish(desktop->status_pubsub, &status); } void desktop_set_dummy_mode_state(Desktop* desktop, bool enabled) { @@ -308,6 +314,8 @@ Desktop* desktop_alloc() { desktop->auto_lock_timer = furi_timer_alloc(desktop_auto_lock_timer_callback, FuriTimerTypeOnce, desktop); + desktop->status_pubsub = furi_pubsub_alloc(); + furi_record_create(RECORD_DESKTOP, desktop); return desktop; @@ -331,6 +339,11 @@ void desktop_api_unlock(Desktop* instance) { view_dispatcher_send_custom_event(instance->view_dispatcher, DesktopLockedEventUnlocked); } +FuriPubSub* desktop_api_get_status_pubsub(Desktop* instance) { + furi_assert(instance); + return instance->status_pubsub; +} + int32_t desktop_srv(void* p) { UNUSED(p); diff --git a/applications/services/desktop/desktop.h b/applications/services/desktop/desktop.h index 5b12647b8a..4eab24fcc5 100644 --- a/applications/services/desktop/desktop.h +++ b/applications/services/desktop/desktop.h @@ -1,5 +1,7 @@ #pragma once +#include + typedef struct Desktop Desktop; #define RECORD_DESKTOP "desktop" @@ -7,3 +9,9 @@ typedef struct Desktop Desktop; bool desktop_api_is_locked(Desktop* instance); void desktop_api_unlock(Desktop* instance); + +typedef struct { + bool locked; +} DesktopStatus; + +FuriPubSub* desktop_api_get_status_pubsub(Desktop* instance); diff --git a/applications/services/desktop/desktop_i.h b/applications/services/desktop/desktop_i.h index ede6bbcc31..0b3d568016 100644 --- a/applications/services/desktop/desktop_i.h +++ b/applications/services/desktop/desktop_i.h @@ -71,6 +71,8 @@ struct Desktop { FuriPubSubSubscription* input_events_subscription; FuriTimer* auto_lock_timer; + FuriPubSub* status_pubsub; + bool in_transition; }; diff --git a/applications/services/rpc/rpc_desktop.c b/applications/services/rpc/rpc_desktop.c index dbf9796ec5..0d72b43d55 100644 --- a/applications/services/rpc/rpc_desktop.c +++ b/applications/services/rpc/rpc_desktop.c @@ -8,6 +8,8 @@ typedef struct { RpcSession* session; Desktop* desktop; + FuriPubSub* status_pubsub; + FuriPubSubSubscription* status_subscription; } RpcDesktop; static void rpc_desktop_on_is_locked_request(const PB_Main* request, void* context) { @@ -39,11 +41,63 @@ static void rpc_desktop_on_unlock_request(const PB_Main* request, void* context) rpc_send_and_release_empty(session, request->command_id, PB_CommandStatus_OK); } +static void rpc_desktop_on_desktop_pubsub(const void* message, void* context) { + RpcDesktop* rpc_desktop = context; + RpcSession* session = rpc_desktop->session; + const DesktopStatus* status = message; + + PB_Main rpc_message = { + .command_id = 0, + .command_status = PB_CommandStatus_OK, + .has_next = false, + .which_content = PB_Main_desktop_status_tag, + .content.desktop_status.locked = status->locked, + }; + rpc_send_and_release(session, &rpc_message); +} + +static void rpc_desktop_on_status_subscribe_request(const PB_Main* request, void* context) { + furi_assert(request); + furi_assert(context); + furi_assert(request->which_content == PB_Main_desktop_status_subscribe_request_tag); + + FURI_LOG_D(TAG, "StatusSubscribeRequest"); + RpcDesktop* rpc_desktop = context; + RpcSession* session = rpc_desktop->session; + + if(rpc_desktop->status_subscription) { + rpc_send_and_release_empty(session, request->command_id, PB_CommandStatus_ERROR); + } else { + rpc_desktop->status_subscription = furi_pubsub_subscribe( + rpc_desktop->status_pubsub, rpc_desktop_on_desktop_pubsub, rpc_desktop); + rpc_send_and_release_empty(session, request->command_id, PB_CommandStatus_OK); + } +} + +static void rpc_desktop_on_status_unsubscribe_request(const PB_Main* request, void* context) { + furi_assert(request); + furi_assert(context); + furi_assert(request->which_content == PB_Main_desktop_status_unsubscribe_request_tag); + + FURI_LOG_D(TAG, "StatusUnsubscribeRequest"); + RpcDesktop* rpc_desktop = context; + RpcSession* session = rpc_desktop->session; + + if(rpc_desktop->status_subscription) { + furi_pubsub_unsubscribe(rpc_desktop->status_pubsub, rpc_desktop->status_subscription); + rpc_desktop->status_subscription = NULL; + rpc_send_and_release_empty(session, request->command_id, PB_CommandStatus_OK); + } else { + rpc_send_and_release_empty(session, request->command_id, PB_CommandStatus_ERROR); + } +} + void* rpc_desktop_alloc(RpcSession* session) { furi_assert(session); RpcDesktop* rpc_desktop = malloc(sizeof(RpcDesktop)); rpc_desktop->desktop = furi_record_open(RECORD_DESKTOP); + rpc_desktop->status_pubsub = desktop_api_get_status_pubsub(rpc_desktop->desktop); rpc_desktop->session = session; RpcHandler rpc_handler = { @@ -58,6 +112,12 @@ void* rpc_desktop_alloc(RpcSession* session) { rpc_handler.message_handler = rpc_desktop_on_unlock_request; rpc_add_handler(session, PB_Main_desktop_unlock_request_tag, &rpc_handler); + rpc_handler.message_handler = rpc_desktop_on_status_subscribe_request; + rpc_add_handler(session, PB_Main_desktop_status_subscribe_request_tag, &rpc_handler); + + rpc_handler.message_handler = rpc_desktop_on_status_unsubscribe_request; + rpc_add_handler(session, PB_Main_desktop_status_unsubscribe_request_tag, &rpc_handler); + return rpc_desktop; } @@ -65,6 +125,10 @@ void rpc_desktop_free(void* context) { furi_assert(context); RpcDesktop* rpc_desktop = context; + if(rpc_desktop->status_subscription) { + furi_pubsub_unsubscribe(rpc_desktop->status_pubsub, rpc_desktop->status_subscription); + } + furi_assert(rpc_desktop->desktop); furi_record_close(RECORD_DESKTOP); diff --git a/assets/protobuf b/assets/protobuf index a13c5ddd03..f71c4b7f75 160000 --- a/assets/protobuf +++ b/assets/protobuf @@ -1 +1 @@ -Subproject commit a13c5ddd0397511bd4c6de4afdd1031a5b6f5bca +Subproject commit f71c4b7f750f2539a1fed08925d8da3abdc80ff9 From faa14cfa1c7f48481d0165776ff320993853fa68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Legrelle?= Date: Thu, 25 May 2023 16:30:07 +0200 Subject: [PATCH 62/92] :sparkles: Add fr-FR-mac key layout (#2666) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- .../resources/badusb/assets/layouts/fr-FR-mac.kl | Bin 0 -> 256 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/resources/badusb/assets/layouts/fr-FR-mac.kl diff --git a/assets/resources/badusb/assets/layouts/fr-FR-mac.kl b/assets/resources/badusb/assets/layouts/fr-FR-mac.kl new file mode 100644 index 0000000000000000000000000000000000000000..0906936547cd3c8accd9632bac82cb4193a24c25 GIT binary patch literal 256 zcmaLLM{dGU007a^2*c-7jOjgKAVDOih=6?{?tg}?*<^Na;Jp*y9N*W!`r*KahgW`G zvn8kCYGsczPfNdC`{Bl|xjXkB{IulBi;9;$9}G>b+c4NP+OloOuBmr3`wpx*a_q#Z zGgmHLIyaAHEaHW;H-;qCX%J` Date: Thu, 25 May 2023 17:38:56 +0300 Subject: [PATCH 63/92] [FL-3322] Infrared: respect carrier frequency and duty cycle settings (#2677) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make infrared_worker respect carrier frequency and duty cycle * Update comments Co-authored-by: あく --- applications/main/infrared/infrared.c | 3 +- firmware/targets/f18/api_symbols.csv | 2 +- firmware/targets/f7/api_symbols.csv | 4 +-- .../targets/f7/furi_hal/furi_hal_infrared.c | 14 +++----- lib/infrared/worker/infrared_worker.c | 32 ++++++++++++------- lib/infrared/worker/infrared_worker.h | 10 ++++-- 6 files changed, 38 insertions(+), 27 deletions(-) diff --git a/applications/main/infrared/infrared.c b/applications/main/infrared/infrared.c index 4f450496d4..685dd57ec0 100644 --- a/applications/main/infrared/infrared.c +++ b/applications/main/infrared/infrared.c @@ -312,7 +312,8 @@ void infrared_tx_start_signal(Infrared* infrared, InfraredSignal* signal) { if(infrared_signal_is_raw(signal)) { InfraredRawSignal* raw = infrared_signal_get_raw_signal(signal); - infrared_worker_set_raw_signal(infrared->worker, raw->timings, raw->timings_size); + infrared_worker_set_raw_signal( + infrared->worker, raw->timings, raw->timings_size, raw->frequency, raw->duty_cycle); } else { InfraredMessage* message = infrared_signal_get_message(signal); infrared_worker_set_decoded_signal(infrared->worker, message); diff --git a/firmware/targets/f18/api_symbols.csv b/firmware/targets/f18/api_symbols.csv index ee1ae11542..b7abdfc050 100644 --- a/firmware/targets/f18/api_symbols.csv +++ b/firmware/targets/f18/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,26.3,, +Version,+,27.0,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index e2bedffb7d..15c19091e9 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,26.3,, +Version,+,27.0,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, @@ -1715,7 +1715,7 @@ Function,+,infrared_worker_rx_set_received_signal_callback,void,"InfraredWorker* Function,+,infrared_worker_rx_start,void,InfraredWorker* Function,+,infrared_worker_rx_stop,void,InfraredWorker* Function,+,infrared_worker_set_decoded_signal,void,"InfraredWorker*, const InfraredMessage*" -Function,+,infrared_worker_set_raw_signal,void,"InfraredWorker*, const uint32_t*, size_t" +Function,+,infrared_worker_set_raw_signal,void,"InfraredWorker*, const uint32_t*, size_t, uint32_t, float" Function,+,infrared_worker_signal_is_decoded,_Bool,const InfraredWorkerSignal* Function,+,infrared_worker_tx_get_signal_steady_callback,InfraredWorkerGetSignalResponse,"void*, InfraredWorker*" Function,+,infrared_worker_tx_set_get_signal_callback,void,"InfraredWorker*, InfraredWorkerGetSignalCallback, void*" diff --git a/firmware/targets/f7/furi_hal/furi_hal_infrared.c b/firmware/targets/f7/furi_hal/furi_hal_infrared.c index 2598e5fa31..7b4f170847 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_infrared.c +++ b/firmware/targets/f7/furi_hal/furi_hal_infrared.c @@ -1,7 +1,6 @@ #include #include #include "stm32wbxx_ll_dma.h" -#include "sys/_stdint.h" #include #include @@ -13,11 +12,10 @@ #include #include -#define INFRARED_TX_DEBUG 0 +// #define INFRARED_TX_DEBUG -#if INFRARED_TX_DEBUG == 1 -#define gpio_infrared_tx gpio_infrared_tx_debug -const GpioPin gpio_infrared_tx_debug = {.port = GPIOA, .pin = GpioModeAnalog}; +#if defined INFRARED_TX_DEBUG +#define gpio_infrared_tx gpio_ext_pa7 #endif #define INFRARED_TIM_TX_DMA_BUFFER_SIZE 200 @@ -330,8 +328,6 @@ static void furi_hal_infrared_tx_dma_isr() { } static void furi_hal_infrared_configure_tim_pwm_tx(uint32_t freq, float duty_cycle) { - /* LL_DBGMCU_APB2_GRP1_FreezePeriph(LL_DBGMCU_APB2_GRP1_TIM1_STOP); */ - LL_TIM_DisableCounter(TIM1); LL_TIM_SetRepetitionCounter(TIM1, 0); LL_TIM_SetCounter(TIM1, 0); @@ -340,7 +336,7 @@ static void furi_hal_infrared_configure_tim_pwm_tx(uint32_t freq, float duty_cyc LL_TIM_EnableARRPreload(TIM1); LL_TIM_SetAutoReload( TIM1, __LL_TIM_CALC_ARR(SystemCoreClock, LL_TIM_GetPrescaler(TIM1), freq)); -#if INFRARED_TX_DEBUG == 1 +#if defined INFRARED_TX_DEBUG LL_TIM_OC_SetCompareCH1(TIM1, ((LL_TIM_GetAutoReload(TIM1) + 1) * (1 - duty_cycle))); LL_TIM_OC_EnablePreload(TIM1, LL_TIM_CHANNEL_CH1); /* LL_TIM_OCMODE_PWM2 set by DMA */ @@ -370,7 +366,7 @@ static void furi_hal_infrared_configure_tim_pwm_tx(uint32_t freq, float duty_cyc static void furi_hal_infrared_configure_tim_cmgr2_dma_tx(void) { LL_DMA_InitTypeDef dma_config = {0}; -#if INFRARED_TX_DEBUG == 1 +#if defined INFRARED_TX_DEBUG dma_config.PeriphOrM2MSrcAddress = (uint32_t) & (TIM1->CCMR1); #else dma_config.PeriphOrM2MSrcAddress = (uint32_t) & (TIM1->CCMR2); diff --git a/lib/infrared/worker/infrared_worker.c b/lib/infrared/worker/infrared_worker.c index 5add1413e9..46effd420d 100644 --- a/lib/infrared/worker/infrared_worker.c +++ b/lib/infrared/worker/infrared_worker.c @@ -40,8 +40,12 @@ struct InfraredWorkerSignal { size_t timings_cnt; union { InfraredMessage message; - /* +1 is for pause we add at the beginning */ - uint32_t timings[MAX_TIMINGS_AMOUNT + 1]; + struct { + /* +1 is for pause we add at the beginning */ + uint32_t timings[MAX_TIMINGS_AMOUNT + 1]; + uint32_t frequency; + float duty_cycle; + } raw; }; }; @@ -146,7 +150,7 @@ static void } if(instance->signal.timings_cnt < MAX_TIMINGS_AMOUNT) { - instance->signal.timings[instance->signal.timings_cnt] = duration; + instance->signal.raw.timings[instance->signal.timings_cnt] = duration; ++instance->signal.timings_cnt; } else { uint32_t flags_set = furi_thread_flags_set( @@ -300,7 +304,7 @@ void infrared_worker_get_raw_signal( furi_assert(timings); furi_assert(timings_cnt); - *timings = signal->timings; + *timings = signal->raw.timings; *timings_cnt = signal->timings_cnt; } @@ -390,8 +394,8 @@ static bool infrared_get_new_signal(InfraredWorker* instance) { infrared_get_protocol_duty_cycle(instance->signal.message.protocol); } else { furi_assert(instance->signal.timings_cnt > 1); - new_tx_frequency = INFRARED_COMMON_CARRIER_FREQUENCY; - new_tx_duty_cycle = INFRARED_COMMON_DUTY_CYCLE; + new_tx_frequency = instance->signal.raw.frequency; + new_tx_duty_cycle = instance->signal.raw.duty_cycle; } instance->tx.tx_raw_cnt = 0; @@ -426,7 +430,7 @@ static bool infrared_worker_tx_fill_buffer(InfraredWorker* instance) { if(instance->signal.decoded) { status = infrared_encode(instance->infrared_encoder, &timing.duration, &timing.level); } else { - timing.duration = instance->signal.timings[instance->tx.tx_raw_cnt]; + timing.duration = instance->signal.raw.timings[instance->tx.tx_raw_cnt]; /* raw always starts from Mark, but we fill it with space delay at start */ timing.level = (instance->tx.tx_raw_cnt % 2); ++instance->tx.tx_raw_cnt; @@ -597,15 +601,21 @@ void infrared_worker_set_decoded_signal(InfraredWorker* instance, const Infrared void infrared_worker_set_raw_signal( InfraredWorker* instance, const uint32_t* timings, - size_t timings_cnt) { + size_t timings_cnt, + uint32_t frequency, + float duty_cycle) { furi_assert(instance); furi_assert(timings); furi_assert(timings_cnt > 0); - size_t max_copy_num = COUNT_OF(instance->signal.timings) - 1; + furi_assert((frequency <= INFRARED_MAX_FREQUENCY) && (frequency >= INFRARED_MIN_FREQUENCY)); + furi_assert((duty_cycle < 1.0f) && (duty_cycle > 0.0f)); + size_t max_copy_num = COUNT_OF(instance->signal.raw.timings) - 1; furi_check(timings_cnt <= max_copy_num); - instance->signal.timings[0] = INFRARED_RAW_TX_TIMING_DELAY_US; - memcpy(&instance->signal.timings[1], timings, timings_cnt * sizeof(uint32_t)); + instance->signal.raw.frequency = frequency; + instance->signal.raw.duty_cycle = duty_cycle; + instance->signal.raw.timings[0] = INFRARED_RAW_TX_TIMING_DELAY_US; + memcpy(&instance->signal.raw.timings[1], timings, timings_cnt * sizeof(uint32_t)); instance->signal.decoded = false; instance->signal.timings_cnt = timings_cnt + 1; } diff --git a/lib/infrared/worker/infrared_worker.h b/lib/infrared/worker/infrared_worker.h index 1a8cd9a76c..e0e8619830 100644 --- a/lib/infrared/worker/infrared_worker.h +++ b/lib/infrared/worker/infrared_worker.h @@ -130,9 +130,9 @@ void infrared_worker_tx_set_signal_sent_callback( /** Callback to pass to infrared_worker_tx_set_get_signal_callback() if signal * is steady and will not be changed between infrared_worker start and stop. * Before starting transmission, desired steady signal must be set with - * infrared_worker_make_decoded_signal() or infrared_worker_make_raw_signal(). + * infrared_worker_set_decoded_signal() or infrared_worker_set_raw_signal(). * - * This function should not be implicitly called. + * This function should not be called directly. * * @param[in] context - context * @param[out] instance - InfraredWorker instance @@ -172,11 +172,15 @@ void infrared_worker_set_decoded_signal(InfraredWorker* instance, const Infrared * @param[out] instance - InfraredWorker instance * @param[in] timings - array of raw timings * @param[in] timings_cnt - size of array of raw timings + * @param[in] frequency - carrier frequency in Hertz + * @param[in] duty_cycle - carrier duty cycle (0.0 - 1.0) */ void infrared_worker_set_raw_signal( InfraredWorker* instance, const uint32_t* timings, - size_t timings_cnt); + size_t timings_cnt, + uint32_t frequency, + float duty_cycle); #ifdef __cplusplus } From 12dc5b186f49dde06b1d11effacd08ba3f55612b Mon Sep 17 00:00:00 2001 From: Nikolay Minaylov Date: Thu, 25 May 2023 17:50:13 +0300 Subject: [PATCH 64/92] USB HID report timeout (#2682) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- firmware/targets/f7/furi_hal/furi_hal_usb_hid.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/firmware/targets/f7/furi_hal/furi_hal_usb_hid.c b/firmware/targets/f7/furi_hal/furi_hal_usb_hid.c index d27613410b..334aa01026 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_usb_hid.c +++ b/firmware/targets/f7/furi_hal/furi_hal_usb_hid.c @@ -436,7 +436,11 @@ static bool hid_send_report(uint8_t report_id) { if((hid_semaphore == NULL) || (hid_connected == false)) return false; if((boot_protocol == true) && (report_id != ReportIdKeyboard)) return false; - furi_check(furi_semaphore_acquire(hid_semaphore, FuriWaitForever) == FuriStatusOk); + FuriStatus status = furi_semaphore_acquire(hid_semaphore, HID_INTERVAL * 2); + if(status == FuriStatusErrorTimeout) { + return false; + } + furi_check(status == FuriStatusOk); if(hid_connected == false) { return false; } From a472ff7a0fbff7c42682e1aa9e2afdfaa3732e4d Mon Sep 17 00:00:00 2001 From: minchogaydarov <134236905+minchogaydarov@users.noreply.github.com> Date: Thu, 25 May 2023 16:00:13 +0100 Subject: [PATCH 65/92] Add Airwell Prime DCI Series and match file style (#2686) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- assets/resources/infrared/assets/ac.ir | 41 ++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/assets/resources/infrared/assets/ac.ir b/assets/resources/infrared/assets/ac.ir index 96a2a0f38e..cfa62f6a24 100644 --- a/assets/resources/infrared/assets/ac.ir +++ b/assets/resources/infrared/assets/ac.ir @@ -297,8 +297,8 @@ type: raw frequency: 38000 duty_cycle: 0.330000 data: 2320 634 837 637 838 637 838 640 835 642 832 1378 836 645 826 670 809 667 808 1406 806 672 803 674 802 1412 802 1412 800 676 801 675 802 1412 802 674 802 1413 801 1412 801 1413 802 1412 802 50937 2285 671 801 1411 802 51225 2280 696 775 1412 801 51212 2283 671 775 1412 802 -# Model: Daikin FTXM20M. # +# Model: Daikin FTXM20M. name: Off type: raw frequency: 38000 @@ -334,8 +334,8 @@ type: raw frequency: 38000 duty_cycle: 0.330000 data: 503 365 500 364 501 366 499 365 500 364 502 25049 3535 1660 504 1228 503 390 474 391 473 393 471 1261 469 397 468 397 469 397 469 397 469 1264 468 398 468 1264 468 1264 468 398 468 1265 467 1265 467 1265 467 1265 467 1265 467 399 467 399 467 1266 466 399 467 400 466 400 466 400 466 423 443 423 443 401 465 423 442 424 442 424 442 1290 442 424 442 1290 442 424 442 424 441 424 442 1290 442 1291 441 425 441 424 442 425 441 425 441 1291 441 425 440 425 441 425 441 425 441 425 441 425 440 425 441 425 441 425 441 425 441 426 440 1292 440 1292 440 1292 440 426 440 426 440 1292 440 1293 439 1293 439 35480 3503 1696 467 1264 468 398 468 398 467 398 468 1265 467 398 467 399 467 399 466 399 467 1265 467 399 467 1266 466 1267 465 400 466 1290 442 1290 442 1290 442 1290 442 1290 442 424 442 424 442 1290 442 424 441 424 442 424 442 424 442 424 442 424 441 424 442 425 441 424 442 425 441 425 441 1291 441 425 441 425 441 425 441 425 440 1292 440 425 441 425 440 426 440 426 440 426 440 426 440 426 440 426 440 426 440 426 439 427 439 426 440 426 440 1293 439 427 439 427 439 427 438 427 439 428 438 1294 438 428 437 428 438 1295 437 1319 413 453 413 35480 3503 1696 468 1265 467 398 468 398 468 398 468 1265 467 398 468 399 466 399 467 399 467 1266 466 399 466 1267 465 1290 442 401 465 1290 442 1290 442 1290 442 1290 442 1290 442 424 442 424 441 1291 441 424 442 424 442 424 442 424 442 424 441 424 442 425 441 424 442 424 441 425 441 425 441 425 440 425 441 425 441 425 441 425 441 425 441 425 441 1292 440 426 440 426 440 1292 440 426 440 426 440 1293 439 426 440 426 440 1293 439 1293 439 1293 439 427 439 1294 438 427 438 427 439 427 438 428 438 428 438 428 438 428 438 453 413 429 437 453 413 1319 413 1320 412 1320 412 1320 412 454 412 1320 412 454 412 1321 411 1321 411 1321 411 1321 411 1321 411 455 410 455 411 455 411 455 410 456 410 456 410 456 410 481 384 481 385 482 383 482 383 483 358 507 359 1374 358 1374 358 508 358 508 358 508 358 509 357 509 357 535 331 535 331 535 330 535 330 536 330 1403 329 1403 329 563 302 564 301 564 302 564 301 565 301 591 274 619 246 593 273 620 245 620 245 621 245 673 189 -# Model: Mitsubishi SRK63HE. # +# Model: Mitsubishi SRK63HE. name: Off type: raw frequency: 38000 @@ -371,3 +371,40 @@ type: raw frequency: 38000 duty_cycle: 0.330000 data: 3234 1525 463 333 462 1127 465 332 462 333 436 1153 518 307 488 1073 518 307 488 308 434 1131 459 1155 435 1156 434 362 433 1159 432 363 432 1159 432 1159 432 1159 433 363 432 363 432 363 433 363 432 1159 433 1159 432 363 432 1159 433 1159 432 363 432 363 432 1159 432 363 433 363 432 1159 432 363 432 363 432 1159 432 1159 432 363 432 1160 432 1160 431 1160 432 1160 431 1160 431 1160 431 364 431 1160 431 1160 431 1160 431 364 431 364 431 364 431 364 431 1160 431 364 431 364 431 364 431 1160 432 1160 431 1160 432 364 431 1160 431 1160 431 1161 431 1161 430 364 431 364 431 364 431 1160 432 364 431 364 431 364 432 364 431 1161 431 1161 431 364 431 364 431 1161 430 364 432 364 431 1161 430 365 431 365 431 1161 430 1161 430 365 431 1161 430 1161 430 365 430 +# +# Model: Airwell Prime DCI Series +name: Off +type: raw +frequency: 38000 +duty_cycle: 0.330000 +data: 3078 3852 2004 888 1054 1824 1045 894 1051 865 2062 861 1078 860 1080 865 1046 894 1015 1883 1945 899 1013 901 1013 901 1012 902 1012 900 1042 927 986 902 1012 927 987 901 1012 902 1012 927 986 903 1011 902 1012 931 1011 931 1011 904 1010 933 1009 928 985 928 986 1885 1944 927 3017 3943 1943 927 985 1915 984 929 985 929 1943 957 984 929 985 928 985 929 985 1886 1943 899 984 930 983 930 984 957 986 929 985 929 985 930 984 930 983 930 984 930 1013 930 984 959 983 931 982 931 983 930 984 930 984 930 984 960 1011 931 984 1918 1939 929 3016 3917 1940 930 982 1916 954 959 954 959 1913 957 955 933 981 959 928 1015 954 1916 1913 959 953 960 957 986 927 1015 928 1015 953 961 927 987 927 986 927 987 927 986 927 1016 927 987 927 1016 926 1044 928 987 926 1015 928 988 926 987 926 988 926 1946 1883 987 3974 +# +name: Dh +type: raw +frequency: 38000 +duty_cycle: 0.330000 +data: 3060 3870 1026 888 1984 886 1026 888 1053 888 1026 887 1055 858 1055 858 1052 860 1024 891 1044 1854 1016 897 1975 1853 1975 925 1015 898 1015 898 1016 897 1016 898 1015 898 1016 898 1015 898 1015 898 1015 899 1015 899 1014 899 1014 899 1016 927 1014 900 1014 899 1014 1856 1974 926 3048 3883 1015 898 1975 897 1014 899 1015 899 1014 900 1014 899 1015 900 1013 900 1014 899 1014 1857 1014 900 1973 1855 1973 899 1012 901 1013 902 1011 926 987 927 987 926 987 927 987 955 987 926 988 926 987 927 1015 927 987 927 987 926 988 926 1016 927 1015 1884 1945 925 3020 3911 986 928 1946 925 986 927 986 928 986 928 986 927 987 927 987 928 986 928 986 1884 987 956 1946 1882 1946 925 986 928 986 927 986 928 985 928 986 928 986 928 986 928 985 928 985 929 959 954 984 930 984 987 931 955 959 956 958 955 959 1968 1891 980 3982 +# +name: Cool_hi +type: raw +frequency: 38000 +duty_cycle: 0.330000 +data: 3054 3879 1977 892 1020 1846 1083 838 1073 840 2031 859 1051 864 1047 864 1077 896 1014 927 986 928 986 928 986 1885 1943 927 985 929 1013 928 986 929 985 928 985 928 985 928 985 929 985 929 985 957 985 928 1015 928 1015 928 985 929 984 929 985 929 985 1886 1943 927 3017 3914 1943 928 984 1886 985 958 984 929 1972 957 984 958 984 929 984 930 984 929 984 930 984 930 983 1887 1942 929 983 930 984 930 984 930 983 959 984 930 984 930 983 930 984 930 984 930 984 930 983 931 983 931 983 959 984 931 983 931 983 1888 1941 930 3014 3943 1914 931 981 1915 955 959 955 959 1913 958 955 959 954 959 955 959 955 959 955 988 955 960 953 1917 1941 959 953 960 953 961 953 961 953 961 927 987 927 987 927 987 926 987 927 1017 926 988 926 988 925 988 925 988 926 988 925 1018 925 1972 1857 1014 3946 +# +name: Cool_lo +type: raw +frequency: 38000 +duty_cycle: 0.330000 +data: 3080 3850 2007 863 1049 1851 1048 888 1054 887 2012 886 1026 887 1025 888 1050 865 1045 1854 2029 871 1041 872 1040 873 1042 899 1043 899 1043 872 1015 898 1016 899 1041 872 1042 872 1015 926 1017 898 1016 927 1016 926 1016 899 1014 898 1015 926 1016 899 1015 898 1015 1856 1973 897 3048 3910 1947 898 1015 1884 1015 925 988 899 2003 953 988 900 1014 954 988 926 987 1857 1972 896 988 899 1014 900 1014 900 1013 927 987 929 1014 929 1013 926 987 927 986 927 987 927 987 927 987 927 986 927 987 927 986 985 958 928 986 927 986 927 1012 1860 1943 927 3018 3914 1943 955 986 1914 986 929 984 928 1944 955 957 930 984 957 985 956 958 1913 1915 956 957 957 956 957 931 1012 957 930 983 958 955 931 982 958 956 960 983 958 956 958 955 958 930 984 930 984 930 984 930 984 930 1013 930 984 930 985 928 1942 1887 983 3977 +# +name: Heat_hi +type: raw +frequency: 38000 +duty_cycle: 0.330000 +data: 3083 3873 2012 1843 2013 1873 1054 888 2011 887 1025 887 1025 887 1052 890 1048 1852 1017 896 1018 895 1018 896 1976 895 1017 898 1016 898 1015 898 1016 897 1016 897 1016 897 1017 897 1016 897 1017 900 1043 899 1014 897 1016 897 1016 898 1016 898 1015 898 1015 1857 1972 896 3048 3911 1947 1853 1975 1854 1015 898 1973 897 1016 927 1015 926 987 926 1016 1857 1014 926 987 899 1015 901 1970 926 987 927 987 926 988 955 988 1013 958 900 1014 926 987 900 1014 900 1014 900 1013 927 986 927 987 927 1016 955 987 927 987 955 987 1884 1946 928 3045 3912 1974 1883 1974 1883 987 927 1974 926 986 927 987 928 987 956 987 1942 986 956 986 928 986 928 1944 926 986 928 985 929 984 929 985 928 986 956 987 928 986 958 984 929 984 930 984 930 983 929 985 958 984 930 984 957 957 956 957 1887 1971 956 4003 +# +name: Heat_lo +type: raw +frequency: 38000 +duty_cycle: 0.330000 +data: 3108 3851 2062 1793 2006 1821 1103 839 2031 859 1085 829 1081 833 1079 836 1045 1911 1973 897 1015 898 1016 899 1041 871 1016 899 1014 898 1015 899 1015 899 1014 899 1041 872 1015 899 1041 872 1041 872 1015 899 1015 899 1041 873 1014 899 1041 873 1014 899 1014 1883 1975 900 3045 3886 1997 1856 1945 1857 1012 927 1945 900 1013 901 1012 901 1013 901 1012 1859 1999 901 1012 930 1012 903 1011 903 1010 903 1011 902 1012 960 1011 928 986 932 1010 903 1011 928 1015 928 985 929 985 928 1014 928 985 929 985 929 984 929 985 928 986 1915 1971 928 3017 3915 1942 1885 1943 1885 985 930 1971 929 984 930 983 930 984 930 984 1887 1942 929 983 960 983 931 982 931 983 932 981 958 985 958 956 958 984 959 954 931 983 932 981 959 955 932 982 959 954 960 982 961 983 933 955 988 955 985 929 1943 1915 958 4003 From 77bb997b0b4bc73a53624af3d1b9391856f70c98 Mon Sep 17 00:00:00 2001 From: Yukai Li Date: Thu, 25 May 2023 10:16:41 -0600 Subject: [PATCH 66/92] desktop: Refactor favorites settings and allow app browser in selection (#2687) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * desktop: Refactor favorites settings and allow app browser in selection * desktop: Gate app browser entry add, just in case * Desktop: simplify favorite application selection * Desktop: refactor favorite application opening routine and cleanup code * Desktop: handle exit from external application selection Co-authored-by: hedger Co-authored-by: あく --- .../services/desktop/desktop_settings.h | 2 - .../desktop/scenes/desktop_scene_main.c | 49 ++++------ .../scenes/desktop_settings_scene_favorite.c | 94 +++++++++---------- 3 files changed, 61 insertions(+), 84 deletions(-) diff --git a/applications/services/desktop/desktop_settings.h b/applications/services/desktop/desktop_settings.h index 5d1b6126fe..7ab39094d1 100644 --- a/applications/services/desktop/desktop_settings.h +++ b/applications/services/desktop/desktop_settings.h @@ -36,8 +36,6 @@ #define MIN_PIN_SIZE 4 #define MAX_APP_LENGTH 128 -#define FAP_LOADER_APP_NAME "Applications" - typedef struct { InputKey data[MAX_PIN_SIZE]; uint8_t length; diff --git a/applications/services/desktop/scenes/desktop_scene_main.c b/applications/services/desktop/scenes/desktop_scene_main.c index 053ac56f1e..d19b5560f9 100644 --- a/applications/services/desktop/scenes/desktop_scene_main.c +++ b/applications/services/desktop/scenes/desktop_scene_main.c @@ -16,6 +16,8 @@ #define SNAKE_GAME_APP EXT_PATH("/apps/Games/snake_game.fap") #define CLOCK_APP EXT_PATH("/apps/Tools/clock.fap") +#define FAP_LOADER_APP_NAME "Applications" + static void desktop_scene_main_new_idle_animation_callback(void* context) { furi_assert(context); Desktop* desktop = context; @@ -77,6 +79,21 @@ static void desktop_scene_main_open_app_or_profile(Desktop* desktop, const char* } while(false); } +static void desktop_scene_main_start_favorite(Desktop* desktop, FavoriteApp* application) { + LoaderStatus status = LoaderStatusErrorInternal; + if(application->is_external) { + status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, application->name_or_path); + } else if(strlen(application->name_or_path) > 0) { + status = loader_start(desktop->loader, application->name_or_path, NULL); + } else { + status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, NULL); + } + + if(status != LoaderStatusOk) { + FURI_LOG_E(TAG, "loader_start failed: %d", status); + } +} + void desktop_scene_main_callback(DesktopEvent event, void* context) { Desktop* desktop = (Desktop*)context; if(desktop->in_transition) return; @@ -141,40 +158,12 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) { case DesktopMainEventOpenFavoritePrimary: DESKTOP_SETTINGS_LOAD(&desktop->settings); - if(desktop->settings.favorite_primary.is_external) { - LoaderStatus status = loader_start( - desktop->loader, - FAP_LOADER_APP_NAME, - desktop->settings.favorite_primary.name_or_path); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } - } else { - LoaderStatus status = loader_start( - desktop->loader, desktop->settings.favorite_primary.name_or_path, NULL); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } - } + desktop_scene_main_start_favorite(desktop, &desktop->settings.favorite_primary); consumed = true; break; case DesktopMainEventOpenFavoriteSecondary: DESKTOP_SETTINGS_LOAD(&desktop->settings); - if(desktop->settings.favorite_secondary.is_external) { - LoaderStatus status = loader_start( - desktop->loader, - FAP_LOADER_APP_NAME, - desktop->settings.favorite_secondary.name_or_path); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } - } else { - LoaderStatus status = loader_start( - desktop->loader, desktop->settings.favorite_secondary.name_or_path, NULL); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } - } + desktop_scene_main_start_favorite(desktop, &desktop->settings.favorite_secondary); consumed = true; break; case DesktopAnimationEventCheckAnimation: diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c index 94c5ee9f04..4b5c479212 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c @@ -5,6 +5,9 @@ #include #include +#define EXTERNAL_APPLICATION_NAME ("[External Application]") +#define EXTERNAL_APPLICATION_INDEX (FLIPPER_APPS_COUNT + 1) + static bool favorite_fap_selector_item_callback( FuriString* file_path, void* context, @@ -44,6 +47,8 @@ void desktop_settings_scene_favorite_on_enter(void* context) { uint32_t primary_favorite = scene_manager_get_scene_state(app->scene_manager, DesktopSettingsAppSceneFavorite); uint32_t pre_select_item = 0; + FavoriteApp* curr_favorite_app = primary_favorite ? &app->settings.favorite_primary : + &app->settings.favorite_secondary; for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) { submenu_add_item( @@ -53,21 +58,25 @@ void desktop_settings_scene_favorite_on_enter(void* context) { desktop_settings_scene_favorite_submenu_callback, app); - if(primary_favorite) { // Select favorite item in submenu - if((app->settings.favorite_primary.is_external && - !strcmp(FLIPPER_APPS[i].name, FAP_LOADER_APP_NAME)) || - (!strcmp(FLIPPER_APPS[i].name, app->settings.favorite_primary.name_or_path))) { - pre_select_item = i; - } - } else { - if((app->settings.favorite_secondary.is_external && - !strcmp(FLIPPER_APPS[i].name, FAP_LOADER_APP_NAME)) || - (!strcmp(FLIPPER_APPS[i].name, app->settings.favorite_secondary.name_or_path))) { - pre_select_item = i; - } + // Select favorite item in submenu + if(!curr_favorite_app->is_external && + !strcmp(FLIPPER_APPS[i].name, curr_favorite_app->name_or_path)) { + pre_select_item = i; } } +#ifdef APP_FAP_LOADER + submenu_add_item( + submenu, + EXTERNAL_APPLICATION_NAME, + EXTERNAL_APPLICATION_INDEX, + desktop_settings_scene_favorite_submenu_callback, + app); + if(curr_favorite_app->is_external) { + pre_select_item = EXTERNAL_APPLICATION_INDEX; + } +#endif + submenu_set_header( submenu, primary_favorite ? "Primary favorite app:" : "Secondary favorite app:"); submenu_set_selected_item(submenu, pre_select_item); // If set during loop, visual glitch. @@ -82,23 +91,11 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e uint32_t primary_favorite = scene_manager_get_scene_state(app->scene_manager, DesktopSettingsAppSceneFavorite); + FavoriteApp* curr_favorite_app = primary_favorite ? &app->settings.favorite_primary : + &app->settings.favorite_secondary; if(event.type == SceneManagerEventTypeCustom) { - if(strcmp(FLIPPER_APPS[event.event].name, FAP_LOADER_APP_NAME) != 0) { - if(primary_favorite) { - app->settings.favorite_primary.is_external = false; - strncpy( - app->settings.favorite_primary.name_or_path, - FLIPPER_APPS[event.event].name, - MAX_APP_LENGTH); - } else { - app->settings.favorite_secondary.is_external = false; - strncpy( - app->settings.favorite_secondary.name_or_path, - FLIPPER_APPS[event.event].name, - MAX_APP_LENGTH); - } - } else { + if(event.event == EXTERNAL_APPLICATION_INDEX) { const DialogsFileBrowserOptions browser_options = { .extension = ".fap", .icon = &I_unknown_10px, @@ -109,36 +106,29 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e .base_path = EXT_PATH("apps"), }; - if(primary_favorite) { // Select favorite fap in file browser - if(favorite_fap_selector_file_exists( - app->settings.favorite_primary.name_or_path)) { - furi_string_set_str(temp_path, app->settings.favorite_primary.name_or_path); - } - } else { - if(favorite_fap_selector_file_exists( - app->settings.favorite_secondary.name_or_path)) { - furi_string_set_str(temp_path, app->settings.favorite_secondary.name_or_path); - } + // Select favorite fap in file browser + if(favorite_fap_selector_file_exists(curr_favorite_app->name_or_path)) { + furi_string_set_str(temp_path, curr_favorite_app->name_or_path); } - submenu_reset(app->submenu); if(dialog_file_browser_show(app->dialogs, temp_path, temp_path, &browser_options)) { - if(primary_favorite) { - app->settings.favorite_primary.is_external = true; - strncpy( - app->settings.favorite_primary.name_or_path, - furi_string_get_cstr(temp_path), - MAX_APP_LENGTH); - } else { - app->settings.favorite_secondary.is_external = true; - strncpy( - app->settings.favorite_secondary.name_or_path, - furi_string_get_cstr(temp_path), - MAX_APP_LENGTH); - } + submenu_reset(app->submenu); // Prevent menu from being shown when we exiting scene + curr_favorite_app->is_external = true; + strncpy( + curr_favorite_app->name_or_path, + furi_string_get_cstr(temp_path), + MAX_APP_LENGTH); + consumed = true; } + } else { + curr_favorite_app->is_external = false; + strncpy( + curr_favorite_app->name_or_path, FLIPPER_APPS[event.event].name, MAX_APP_LENGTH); + consumed = true; } - scene_manager_previous_scene(app->scene_manager); + if(consumed) { + scene_manager_previous_scene(app->scene_manager); + }; consumed = true; } From 490447bbd482126063bce3e5378198365b580963 Mon Sep 17 00:00:00 2001 From: Avery <30564701+nullableVoidPtr@users.noreply.github.com> Date: Fri, 26 May 2023 03:01:02 +1000 Subject: [PATCH 67/92] NFC: Add support for Gen4 "ultimate card" in Magic app (#2238) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * NFC: gen4 gtu detect in magic app * NFC: more support for GTU card * NFC: Fix Gen1 in Magic * Allow double UIDs for MFClassic on GTU cards * NFC: Small magic app tweaks * nfc magic: notify card event on wiping * nfc magic: fix power consumption * nfc magic: disable i2c writing and fix wipe loop * NfcMagic: correct formatting in printf * NfcMagic: correct formatting in printf, proper version * nfc_magic: rework card found notification and gen4 wiping Co-authored-by: あく --- .../nfc_magic/lib/magic/classic_gen1.c | 175 ++++++++ .../nfc_magic/lib/magic/classic_gen1.h | 13 + .../external/nfc_magic/lib/magic/common.c | 33 ++ .../external/nfc_magic/lib/magic/common.h | 19 + .../external/nfc_magic/lib/magic/gen4.c | 199 ++++++++++ .../external/nfc_magic/lib/magic/gen4.h | 48 +++ .../external/nfc_magic/lib/magic/magic.c | 52 +-- .../external/nfc_magic/lib/magic/magic.h | 15 - .../external/nfc_magic/lib/magic/types.c | 23 ++ .../external/nfc_magic/lib/magic/types.h | 5 + applications/external/nfc_magic/nfc_magic.c | 22 +- applications/external/nfc_magic/nfc_magic.h | 2 + applications/external/nfc_magic/nfc_magic_i.h | 20 +- .../external/nfc_magic/nfc_magic_worker.c | 372 +++++++++++++++--- .../external/nfc_magic/nfc_magic_worker.h | 4 + .../external/nfc_magic/nfc_magic_worker_i.h | 5 + .../scenes/nfc_magic_scene_actions.c | 50 +++ .../nfc_magic/scenes/nfc_magic_scene_check.c | 4 +- .../nfc_magic/scenes/nfc_magic_scene_config.h | 6 + .../scenes/nfc_magic_scene_file_select.c | 60 ++- .../scenes/nfc_magic_scene_gen4_actions.c | 70 ++++ .../scenes/nfc_magic_scene_key_input.c | 45 +++ .../scenes/nfc_magic_scene_magic_info.c | 14 + .../scenes/nfc_magic_scene_new_key_input.c | 45 +++ .../nfc_magic/scenes/nfc_magic_scene_rekey.c | 95 +++++ .../scenes/nfc_magic_scene_rekey_fail.c | 50 +++ .../nfc_magic/scenes/nfc_magic_scene_start.c | 25 +- .../nfc_magic/scenes/nfc_magic_scene_wipe.c | 11 +- .../nfc_magic/scenes/nfc_magic_scene_write.c | 11 +- .../scenes/nfc_magic_scene_wrong_card.c | 2 +- 30 files changed, 1345 insertions(+), 150 deletions(-) create mode 100644 applications/external/nfc_magic/lib/magic/classic_gen1.c create mode 100644 applications/external/nfc_magic/lib/magic/classic_gen1.h create mode 100644 applications/external/nfc_magic/lib/magic/common.c create mode 100644 applications/external/nfc_magic/lib/magic/common.h create mode 100644 applications/external/nfc_magic/lib/magic/gen4.c create mode 100644 applications/external/nfc_magic/lib/magic/gen4.h delete mode 100644 applications/external/nfc_magic/lib/magic/magic.h create mode 100644 applications/external/nfc_magic/lib/magic/types.c create mode 100644 applications/external/nfc_magic/lib/magic/types.h create mode 100644 applications/external/nfc_magic/scenes/nfc_magic_scene_actions.c create mode 100644 applications/external/nfc_magic/scenes/nfc_magic_scene_gen4_actions.c create mode 100644 applications/external/nfc_magic/scenes/nfc_magic_scene_key_input.c create mode 100644 applications/external/nfc_magic/scenes/nfc_magic_scene_new_key_input.c create mode 100644 applications/external/nfc_magic/scenes/nfc_magic_scene_rekey.c create mode 100644 applications/external/nfc_magic/scenes/nfc_magic_scene_rekey_fail.c diff --git a/applications/external/nfc_magic/lib/magic/classic_gen1.c b/applications/external/nfc_magic/lib/magic/classic_gen1.c new file mode 100644 index 0000000000..ebd2b08057 --- /dev/null +++ b/applications/external/nfc_magic/lib/magic/classic_gen1.c @@ -0,0 +1,175 @@ +#include "classic_gen1.h" + +#include + +#define TAG "Magic" + +#define MAGIC_CMD_WUPA (0x40) +#define MAGIC_CMD_WIPE (0x41) +#define MAGIC_CMD_ACCESS (0x43) + +#define MAGIC_MIFARE_READ_CMD (0x30) +#define MAGIC_MIFARE_WRITE_CMD (0xA0) + +#define MAGIC_ACK (0x0A) + +#define MAGIC_BUFFER_SIZE (32) + +bool magic_gen1_wupa() { + bool magic_activated = false; + uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; + uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; + uint16_t rx_len = 0; + FuriHalNfcReturn ret = 0; + + do { + // Start communication + tx_data[0] = MAGIC_CMD_WUPA; + ret = furi_hal_nfc_ll_txrx_bits( + tx_data, + 7, + rx_data, + sizeof(rx_data), + &rx_len, + FURI_HAL_NFC_LL_TXRX_FLAGS_CRC_TX_MANUAL | FURI_HAL_NFC_LL_TXRX_FLAGS_AGC_ON | + FURI_HAL_NFC_LL_TXRX_FLAGS_CRC_RX_KEEP, + furi_hal_nfc_ll_ms2fc(20)); + if(ret != FuriHalNfcReturnIncompleteByte) break; + if(rx_len != 4) break; + if(rx_data[0] != MAGIC_ACK) break; + magic_activated = true; + } while(false); + + return magic_activated; +} + +bool magic_gen1_data_access_cmd() { + bool write_cmd_success = false; + uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; + uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; + uint16_t rx_len = 0; + FuriHalNfcReturn ret = 0; + + do { + tx_data[0] = MAGIC_CMD_ACCESS; + ret = furi_hal_nfc_ll_txrx_bits( + tx_data, + 8, + rx_data, + sizeof(rx_data), + &rx_len, + FURI_HAL_NFC_LL_TXRX_FLAGS_CRC_TX_MANUAL | FURI_HAL_NFC_LL_TXRX_FLAGS_AGC_ON | + FURI_HAL_NFC_LL_TXRX_FLAGS_CRC_RX_KEEP, + furi_hal_nfc_ll_ms2fc(20)); + if(ret != FuriHalNfcReturnIncompleteByte) break; + if(rx_len != 4) break; + if(rx_data[0] != MAGIC_ACK) break; + + write_cmd_success = true; + } while(false); + + return write_cmd_success; +} + +bool magic_gen1_read_block(uint8_t block_num, MfClassicBlock* data) { + furi_assert(data); + + bool read_success = false; + + uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; + uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; + uint16_t rx_len = 0; + FuriHalNfcReturn ret = 0; + + do { + tx_data[0] = MAGIC_MIFARE_READ_CMD; + tx_data[1] = block_num; + ret = furi_hal_nfc_ll_txrx_bits( + tx_data, + 2 * 8, + rx_data, + sizeof(rx_data), + &rx_len, + FURI_HAL_NFC_LL_TXRX_FLAGS_AGC_ON, + furi_hal_nfc_ll_ms2fc(20)); + + if(ret != FuriHalNfcReturnOk) break; + if(rx_len != 16 * 8) break; + memcpy(data->value, rx_data, sizeof(data->value)); + read_success = true; + } while(false); + + return read_success; +} + +bool magic_gen1_write_blk(uint8_t block_num, MfClassicBlock* data) { + furi_assert(data); + + bool write_success = false; + uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; + uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; + uint16_t rx_len = 0; + FuriHalNfcReturn ret = 0; + + do { + tx_data[0] = MAGIC_MIFARE_WRITE_CMD; + tx_data[1] = block_num; + ret = furi_hal_nfc_ll_txrx_bits( + tx_data, + 2 * 8, + rx_data, + sizeof(rx_data), + &rx_len, + FURI_HAL_NFC_LL_TXRX_FLAGS_AGC_ON | FURI_HAL_NFC_LL_TXRX_FLAGS_CRC_RX_KEEP, + furi_hal_nfc_ll_ms2fc(20)); + if(ret != FuriHalNfcReturnIncompleteByte) break; + if(rx_len != 4) break; + if(rx_data[0] != MAGIC_ACK) break; + + memcpy(tx_data, data->value, sizeof(data->value)); + ret = furi_hal_nfc_ll_txrx_bits( + tx_data, + 16 * 8, + rx_data, + sizeof(rx_data), + &rx_len, + FURI_HAL_NFC_LL_TXRX_FLAGS_AGC_ON | FURI_HAL_NFC_LL_TXRX_FLAGS_CRC_RX_KEEP, + furi_hal_nfc_ll_ms2fc(20)); + if(ret != FuriHalNfcReturnIncompleteByte) break; + if(rx_len != 4) break; + if(rx_data[0] != MAGIC_ACK) break; + + write_success = true; + } while(false); + + return write_success; +} + +bool magic_gen1_wipe() { + bool wipe_success = false; + uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; + uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; + uint16_t rx_len = 0; + FuriHalNfcReturn ret = 0; + + do { + tx_data[0] = MAGIC_CMD_WIPE; + ret = furi_hal_nfc_ll_txrx_bits( + tx_data, + 8, + rx_data, + sizeof(rx_data), + &rx_len, + FURI_HAL_NFC_LL_TXRX_FLAGS_CRC_TX_MANUAL | FURI_HAL_NFC_LL_TXRX_FLAGS_AGC_ON | + FURI_HAL_NFC_LL_TXRX_FLAGS_CRC_RX_KEEP, + furi_hal_nfc_ll_ms2fc(2000)); + + if(ret != FuriHalNfcReturnIncompleteByte) break; + if(rx_len != 4) break; + if(rx_data[0] != MAGIC_ACK) break; + + wipe_success = true; + } while(false); + + return wipe_success; +} \ No newline at end of file diff --git a/applications/external/nfc_magic/lib/magic/classic_gen1.h b/applications/external/nfc_magic/lib/magic/classic_gen1.h new file mode 100644 index 0000000000..6d4ff6dcd9 --- /dev/null +++ b/applications/external/nfc_magic/lib/magic/classic_gen1.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +bool magic_gen1_wupa(); + +bool magic_gen1_read_block(uint8_t block_num, MfClassicBlock* data); + +bool magic_gen1_data_access_cmd(); + +bool magic_gen1_write_blk(uint8_t block_num, MfClassicBlock* data); + +bool magic_gen1_wipe(); \ No newline at end of file diff --git a/applications/external/nfc_magic/lib/magic/common.c b/applications/external/nfc_magic/lib/magic/common.c new file mode 100644 index 0000000000..0ea3cb218d --- /dev/null +++ b/applications/external/nfc_magic/lib/magic/common.c @@ -0,0 +1,33 @@ +#include "common.h" + +#include + +#define REQA (0x26) +#define CL1_PREFIX (0x93) +#define SELECT (0x70) + +#define MAGIC_BUFFER_SIZE (32) + +bool magic_activate() { + FuriHalNfcReturn ret = 0; + + // Setup nfc poller + furi_hal_nfc_exit_sleep(); + furi_hal_nfc_ll_txrx_on(); + furi_hal_nfc_ll_poll(); + ret = furi_hal_nfc_ll_set_mode( + FuriHalNfcModePollNfca, FuriHalNfcBitrate106, FuriHalNfcBitrate106); + if(ret != FuriHalNfcReturnOk) return false; + + furi_hal_nfc_ll_set_fdt_listen(FURI_HAL_NFC_LL_FDT_LISTEN_NFCA_POLLER); + furi_hal_nfc_ll_set_fdt_poll(FURI_HAL_NFC_LL_FDT_POLL_NFCA_POLLER); + furi_hal_nfc_ll_set_error_handling(FuriHalNfcErrorHandlingNfc); + furi_hal_nfc_ll_set_guard_time(FURI_HAL_NFC_LL_GT_NFCA); + + return true; +} + +void magic_deactivate() { + furi_hal_nfc_ll_txrx_off(); + furi_hal_nfc_sleep(); +} \ No newline at end of file diff --git a/applications/external/nfc_magic/lib/magic/common.h b/applications/external/nfc_magic/lib/magic/common.h new file mode 100644 index 0000000000..bef166c8f2 --- /dev/null +++ b/applications/external/nfc_magic/lib/magic/common.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +typedef enum { + MagicTypeClassicGen1, + MagicTypeClassicDirectWrite, + MagicTypeClassicAPDU, + MagicTypeUltralightGen1, + MagicTypeUltralightDirectWrite, + MagicTypeUltralightC_Gen1, + MagicTypeUltralightC_DirectWrite, + MagicTypeGen4, +} MagicType; + +bool magic_activate(); + +void magic_deactivate(); \ No newline at end of file diff --git a/applications/external/nfc_magic/lib/magic/gen4.c b/applications/external/nfc_magic/lib/magic/gen4.c new file mode 100644 index 0000000000..31be649a04 --- /dev/null +++ b/applications/external/nfc_magic/lib/magic/gen4.c @@ -0,0 +1,199 @@ +#include "gen4.h" + +#include +#include + +#define TAG "Magic" + +#define MAGIC_CMD_PREFIX (0xCF) + +#define MAGIC_CMD_GET_CFG (0xC6) +#define MAGIC_CMD_WRITE (0xCD) +#define MAGIC_CMD_READ (0xCE) +#define MAGIC_CMD_SET_CFG (0xF0) +#define MAGIC_CMD_FUSE_CFG (0xF1) +#define MAGIC_CMD_SET_PWD (0xFE) + +#define MAGIC_BUFFER_SIZE (40) + +const uint8_t MAGIC_DEFAULT_CONFIG[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x09, 0x78, 0x00, 0x91, 0x02, 0xDA, 0xBC, 0x19, 0x10, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x04, 0x00, 0x08, 0x00 +}; + +const uint8_t MAGIC_DEFAULT_BLOCK0[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +const uint8_t MAGIC_EMPTY_BLOCK[16] = { 0 }; + +const uint8_t MAGIC_DEFAULT_SECTOR_TRAILER[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x80, 0x69, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +static bool magic_gen4_is_block_num_trailer(uint8_t n) { + n++; + if (n < 32 * 4) { + return (n % 4 == 0); + } + + return (n % 16 == 0); +} + +bool magic_gen4_get_cfg(uint32_t pwd, uint8_t* config) { + bool is_valid_config_len = false; + uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; + uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; + uint16_t rx_len = 0; + FuriHalNfcReturn ret = 0; + + do { + // Start communication + tx_data[0] = MAGIC_CMD_PREFIX; + tx_data[1] = (uint8_t)(pwd >> 24); + tx_data[2] = (uint8_t)(pwd >> 16); + tx_data[3] = (uint8_t)(pwd >> 8); + tx_data[4] = (uint8_t)pwd; + tx_data[5] = MAGIC_CMD_GET_CFG; + ret = furi_hal_nfc_ll_txrx( + tx_data, + 6, + rx_data, + sizeof(rx_data), + &rx_len, + FURI_HAL_NFC_TXRX_DEFAULT, + furi_hal_nfc_ll_ms2fc(20)); + if(ret != FuriHalNfcReturnOk) break; + if(rx_len != 30 && rx_len != 32) break; + memcpy(config, rx_data, rx_len); + is_valid_config_len = true; + } while(false); + + return is_valid_config_len; +} + +bool magic_gen4_set_cfg(uint32_t pwd, const uint8_t* config, uint8_t config_length, bool fuse) { + bool write_success = false; + uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; + uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; + uint16_t rx_len = 0; + FuriHalNfcReturn ret = 0; + + do { + // Start communication + tx_data[0] = MAGIC_CMD_PREFIX; + tx_data[1] = (uint8_t)(pwd >> 24); + tx_data[2] = (uint8_t)(pwd >> 16); + tx_data[3] = (uint8_t)(pwd >> 8); + tx_data[4] = (uint8_t)pwd; + tx_data[5] = fuse ? MAGIC_CMD_FUSE_CFG : MAGIC_CMD_SET_CFG; + memcpy(tx_data + 6, config, config_length); + ret = furi_hal_nfc_ll_txrx( + tx_data, + 6 + config_length, + rx_data, + sizeof(rx_data), + &rx_len, + FURI_HAL_NFC_TXRX_DEFAULT, + furi_hal_nfc_ll_ms2fc(20)); + if(ret != FuriHalNfcReturnOk) break; + if(rx_len != 2) break; + write_success = true; + } while(false); + + return write_success; +} + +bool magic_gen4_set_pwd(uint32_t old_pwd, uint32_t new_pwd) { + bool change_success = false; + uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; + uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; + uint16_t rx_len = 0; + FuriHalNfcReturn ret = 0; + + do { + // Start communication + tx_data[0] = MAGIC_CMD_PREFIX; + tx_data[1] = (uint8_t)(old_pwd >> 24); + tx_data[2] = (uint8_t)(old_pwd >> 16); + tx_data[3] = (uint8_t)(old_pwd >> 8); + tx_data[4] = (uint8_t)old_pwd; + tx_data[5] = MAGIC_CMD_SET_PWD; + tx_data[6] = (uint8_t)(new_pwd >> 24); + tx_data[7] = (uint8_t)(new_pwd >> 16); + tx_data[8] = (uint8_t)(new_pwd >> 8); + tx_data[9] = (uint8_t)new_pwd; + ret = furi_hal_nfc_ll_txrx( + tx_data, + 10, + rx_data, + sizeof(rx_data), + &rx_len, + FURI_HAL_NFC_TXRX_DEFAULT, + furi_hal_nfc_ll_ms2fc(20)); + FURI_LOG_I(TAG, "ret %d, len %d", ret, rx_len); + if(ret != FuriHalNfcReturnOk) break; + if(rx_len != 2) break; + change_success = true; + } while(false); + + return change_success; +} + +bool magic_gen4_write_blk(uint32_t pwd, uint8_t block_num, const uint8_t* data) { + bool write_success = false; + uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; + uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; + uint16_t rx_len = 0; + FuriHalNfcReturn ret = 0; + + do { + // Start communication + tx_data[0] = MAGIC_CMD_PREFIX; + tx_data[1] = (uint8_t)(pwd >> 24); + tx_data[2] = (uint8_t)(pwd >> 16); + tx_data[3] = (uint8_t)(pwd >> 8); + tx_data[4] = (uint8_t)pwd; + tx_data[5] = MAGIC_CMD_WRITE; + tx_data[6] = block_num; + memcpy(tx_data + 7, data, 16); + ret = furi_hal_nfc_ll_txrx( + tx_data, + 23, + rx_data, + sizeof(rx_data), + &rx_len, + FURI_HAL_NFC_TXRX_DEFAULT, + furi_hal_nfc_ll_ms2fc(200)); + if(ret != FuriHalNfcReturnOk) break; + if(rx_len != 2) break; + write_success = true; + } while(false); + + return write_success; +} + +bool magic_gen4_wipe(uint32_t pwd) { + if(!magic_gen4_set_cfg(pwd, MAGIC_DEFAULT_CONFIG, sizeof(MAGIC_DEFAULT_CONFIG), false)) { + FURI_LOG_E(TAG, "Set config failed"); + return false; + } + if(!magic_gen4_write_blk(pwd, 0, MAGIC_DEFAULT_BLOCK0)) { + FURI_LOG_E(TAG, "Block 0 write failed"); + return false; + } + for(size_t i = 1; i < 64; i++) { + const uint8_t* block = magic_gen4_is_block_num_trailer(i) ? MAGIC_DEFAULT_SECTOR_TRAILER : MAGIC_EMPTY_BLOCK; + if(!magic_gen4_write_blk(pwd, i, block)) { + FURI_LOG_E(TAG, "Block %d write failed", i); + return false; + } + } + for(size_t i = 65; i < 256; i++) { + if(!magic_gen4_write_blk(pwd, i, MAGIC_EMPTY_BLOCK)) { + FURI_LOG_E(TAG, "Block %d write failed", i); + return false; + } + } + + return true; +} \ No newline at end of file diff --git a/applications/external/nfc_magic/lib/magic/gen4.h b/applications/external/nfc_magic/lib/magic/gen4.h new file mode 100644 index 0000000000..c515af820b --- /dev/null +++ b/applications/external/nfc_magic/lib/magic/gen4.h @@ -0,0 +1,48 @@ +#pragma once + +#include + +#define MAGIC_GEN4_DEFAULT_PWD 0x00000000 +#define MAGIC_GEN4_CONFIG_LEN 32 + +#define NFCID1_SINGLE_SIZE 4 +#define NFCID1_DOUBLE_SIZE 7 +#define NFCID1_TRIPLE_SIZE 10 + +typedef enum { + MagicGen4UIDLengthSingle = 0x00, + MagicGen4UIDLengthDouble = 0x01, + MagicGen4UIDLengthTriple = 0x02 +} MagicGen4UIDLength; + +typedef enum { + MagicGen4UltralightModeUL_EV1 = 0x00, + MagicGen4UltralightModeNTAG = 0x01, + MagicGen4UltralightModeUL_C = 0x02, + MagicGen4UltralightModeUL = 0x03 +} MagicGen4UltralightMode; + +typedef enum { + // for writing original (shadow) data + MagicGen4ShadowModePreWrite = 0x00, + // written data can be read once before restored to original + MagicGen4ShadowModeRestore = 0x01, + // written data is discarded + MagicGen4ShadowModeIgnore = 0x02, + // apparently for UL? + MagicGen4ShadowModeHighSpeedIgnore = 0x03 +} MagicGen4ShadowMode; + +bool magic_gen4_get_cfg(uint32_t pwd, uint8_t* config); + +bool magic_gen4_set_cfg(uint32_t pwd, const uint8_t* config, uint8_t config_length, bool fuse); + +bool magic_gen4_set_pwd(uint32_t old_pwd, uint32_t new_pwd); + +bool magic_gen4_read_blk(uint32_t pwd, uint8_t block_num, uint8_t* data); + +bool magic_gen4_write_blk(uint32_t pwd, uint8_t block_num, const uint8_t* data); + +bool magic_gen4_wipe(uint32_t pwd); + +void magic_gen4_deactivate(); diff --git a/applications/external/nfc_magic/lib/magic/magic.c b/applications/external/nfc_magic/lib/magic/magic.c index 9a71daaa0f..ebd2b08057 100644 --- a/applications/external/nfc_magic/lib/magic/magic.c +++ b/applications/external/nfc_magic/lib/magic/magic.c @@ -1,4 +1,4 @@ -#include "magic.h" +#include "classic_gen1.h" #include @@ -15,7 +15,7 @@ #define MAGIC_BUFFER_SIZE (32) -bool magic_wupa() { +bool magic_gen1_wupa() { bool magic_activated = false; uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; @@ -23,19 +23,6 @@ bool magic_wupa() { FuriHalNfcReturn ret = 0; do { - // Setup nfc poller - furi_hal_nfc_exit_sleep(); - furi_hal_nfc_ll_txrx_on(); - furi_hal_nfc_ll_poll(); - ret = furi_hal_nfc_ll_set_mode( - FuriHalNfcModePollNfca, FuriHalNfcBitrate106, FuriHalNfcBitrate106); - if(ret != FuriHalNfcReturnOk) break; - - furi_hal_nfc_ll_set_fdt_listen(FURI_HAL_NFC_LL_FDT_LISTEN_NFCA_POLLER); - furi_hal_nfc_ll_set_fdt_poll(FURI_HAL_NFC_LL_FDT_POLL_NFCA_POLLER); - furi_hal_nfc_ll_set_error_handling(FuriHalNfcErrorHandlingNfc); - furi_hal_nfc_ll_set_guard_time(FURI_HAL_NFC_LL_GT_NFCA); - // Start communication tx_data[0] = MAGIC_CMD_WUPA; ret = furi_hal_nfc_ll_txrx_bits( @@ -53,15 +40,10 @@ bool magic_wupa() { magic_activated = true; } while(false); - if(!magic_activated) { - furi_hal_nfc_ll_txrx_off(); - furi_hal_nfc_start_sleep(); - } - return magic_activated; } -bool magic_data_access_cmd() { +bool magic_gen1_data_access_cmd() { bool write_cmd_success = false; uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; @@ -86,15 +68,10 @@ bool magic_data_access_cmd() { write_cmd_success = true; } while(false); - if(!write_cmd_success) { - furi_hal_nfc_ll_txrx_off(); - furi_hal_nfc_start_sleep(); - } - return write_cmd_success; } -bool magic_read_block(uint8_t block_num, MfClassicBlock* data) { +bool magic_gen1_read_block(uint8_t block_num, MfClassicBlock* data) { furi_assert(data); bool read_success = false; @@ -122,15 +99,10 @@ bool magic_read_block(uint8_t block_num, MfClassicBlock* data) { read_success = true; } while(false); - if(!read_success) { - furi_hal_nfc_ll_txrx_off(); - furi_hal_nfc_start_sleep(); - } - return read_success; } -bool magic_write_blk(uint8_t block_num, MfClassicBlock* data) { +bool magic_gen1_write_blk(uint8_t block_num, MfClassicBlock* data) { furi_assert(data); bool write_success = false; @@ -170,15 +142,10 @@ bool magic_write_blk(uint8_t block_num, MfClassicBlock* data) { write_success = true; } while(false); - if(!write_success) { - furi_hal_nfc_ll_txrx_off(); - furi_hal_nfc_start_sleep(); - } - return write_success; } -bool magic_wipe() { +bool magic_gen1_wipe() { bool wipe_success = false; uint8_t tx_data[MAGIC_BUFFER_SIZE] = {}; uint8_t rx_data[MAGIC_BUFFER_SIZE] = {}; @@ -205,9 +172,4 @@ bool magic_wipe() { } while(false); return wipe_success; -} - -void magic_deactivate() { - furi_hal_nfc_ll_txrx_off(); - furi_hal_nfc_sleep(); -} +} \ No newline at end of file diff --git a/applications/external/nfc_magic/lib/magic/magic.h b/applications/external/nfc_magic/lib/magic/magic.h deleted file mode 100644 index 64c60a0a70..0000000000 --- a/applications/external/nfc_magic/lib/magic/magic.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -bool magic_wupa(); - -bool magic_read_block(uint8_t block_num, MfClassicBlock* data); - -bool magic_data_access_cmd(); - -bool magic_write_blk(uint8_t block_num, MfClassicBlock* data); - -bool magic_wipe(); - -void magic_deactivate(); diff --git a/applications/external/nfc_magic/lib/magic/types.c b/applications/external/nfc_magic/lib/magic/types.c new file mode 100644 index 0000000000..77c6c0a4ef --- /dev/null +++ b/applications/external/nfc_magic/lib/magic/types.c @@ -0,0 +1,23 @@ +#include "types.h" + +const char* nfc_magic_type(MagicType type) { + if(type == MagicTypeClassicGen1) { + return "Classic Gen 1A/B"; + } else if(type == MagicTypeClassicDirectWrite) { + return "Classic DirectWrite"; + } else if(type == MagicTypeClassicAPDU) { + return "Classic APDU"; + } else if(type == MagicTypeUltralightGen1) { + return "Ultralight Gen 1"; + } else if(type == MagicTypeUltralightDirectWrite) { + return "Ultralight DirectWrite"; + } else if(type == MagicTypeUltralightC_Gen1) { + return "Ultralight-C Gen 1"; + } else if(type == MagicTypeUltralightC_DirectWrite) { + return "Ultralight-C DirectWrite"; + } else if(type == MagicTypeGen4) { + return "Gen 4 GTU"; + } else { + return "Unknown"; + } +} diff --git a/applications/external/nfc_magic/lib/magic/types.h b/applications/external/nfc_magic/lib/magic/types.h new file mode 100644 index 0000000000..dbf5540637 --- /dev/null +++ b/applications/external/nfc_magic/lib/magic/types.h @@ -0,0 +1,5 @@ +#pragma once + +#include "common.h" + +const char* nfc_magic_type(MagicType type); \ No newline at end of file diff --git a/applications/external/nfc_magic/nfc_magic.c b/applications/external/nfc_magic/nfc_magic.c index 1805f35ed0..68c9a65b5f 100644 --- a/applications/external/nfc_magic/nfc_magic.c +++ b/applications/external/nfc_magic/nfc_magic.c @@ -48,8 +48,9 @@ NfcMagic* nfc_magic_alloc() { nfc_magic->view_dispatcher, nfc_magic_tick_event_callback, 100); // Nfc device - nfc_magic->nfc_dev = nfc_device_alloc(); - furi_string_set(nfc_magic->nfc_dev->folder, NFC_APP_FOLDER); + nfc_magic->dev = malloc(sizeof(NfcMagicDevice)); + nfc_magic->source_dev = nfc_device_alloc(); + furi_string_set(nfc_magic->source_dev->folder, NFC_APP_FOLDER); // Open GUI record nfc_magic->gui = furi_record_open(RECORD_GUI); @@ -81,6 +82,13 @@ NfcMagic* nfc_magic_alloc() { NfcMagicViewTextInput, text_input_get_view(nfc_magic->text_input)); + // Byte Input + nfc_magic->byte_input = byte_input_alloc(); + view_dispatcher_add_view( + nfc_magic->view_dispatcher, + NfcMagicViewByteInput, + byte_input_get_view(nfc_magic->byte_input)); + // Custom Widget nfc_magic->widget = widget_alloc(); view_dispatcher_add_view( @@ -93,7 +101,8 @@ void nfc_magic_free(NfcMagic* nfc_magic) { furi_assert(nfc_magic); // Nfc device - nfc_device_free(nfc_magic->nfc_dev); + free(nfc_magic->dev); + nfc_device_free(nfc_magic->source_dev); // Submenu view_dispatcher_remove_view(nfc_magic->view_dispatcher, NfcMagicViewMenu); @@ -107,10 +116,14 @@ void nfc_magic_free(NfcMagic* nfc_magic) { view_dispatcher_remove_view(nfc_magic->view_dispatcher, NfcMagicViewLoading); loading_free(nfc_magic->loading); - // TextInput + // Text Input view_dispatcher_remove_view(nfc_magic->view_dispatcher, NfcMagicViewTextInput); text_input_free(nfc_magic->text_input); + // Byte Input + view_dispatcher_remove_view(nfc_magic->view_dispatcher, NfcMagicViewByteInput); + byte_input_free(nfc_magic->byte_input); + // Custom Widget view_dispatcher_remove_view(nfc_magic->view_dispatcher, NfcMagicViewWidget); widget_free(nfc_magic->widget); @@ -164,6 +177,7 @@ int32_t nfc_magic_app(void* p) { view_dispatcher_run(nfc_magic->view_dispatcher); + magic_deactivate(); nfc_magic_free(nfc_magic); return 0; diff --git a/applications/external/nfc_magic/nfc_magic.h b/applications/external/nfc_magic/nfc_magic.h index 1abf1371ed..f9cf395d82 100644 --- a/applications/external/nfc_magic/nfc_magic.h +++ b/applications/external/nfc_magic/nfc_magic.h @@ -1,3 +1,5 @@ #pragma once +typedef struct NfcMagicDevice NfcMagicDevice; + typedef struct NfcMagic NfcMagic; diff --git a/applications/external/nfc_magic/nfc_magic_i.h b/applications/external/nfc_magic/nfc_magic_i.h index 378912e5b0..4d6b89103d 100644 --- a/applications/external/nfc_magic/nfc_magic_i.h +++ b/applications/external/nfc_magic/nfc_magic_i.h @@ -3,7 +3,10 @@ #include "nfc_magic.h" #include "nfc_magic_worker.h" -#include "lib/magic/magic.h" +#include "lib/magic/common.h" +#include "lib/magic/types.h" +#include "lib/magic/classic_gen1.h" +#include "lib/magic/gen4.h" #include #include @@ -15,6 +18,7 @@ #include #include #include +#include #include #include @@ -39,14 +43,22 @@ enum NfcMagicCustomEvent { NfcMagicCustomEventTextInputDone, }; +struct NfcMagicDevice { + MagicType type; + uint32_t cuid; + uint32_t password; +}; + struct NfcMagic { NfcMagicWorker* worker; ViewDispatcher* view_dispatcher; Gui* gui; NotificationApp* notifications; SceneManager* scene_manager; - // NfcMagicDevice* dev; - NfcDevice* nfc_dev; + struct NfcMagicDevice* dev; + NfcDevice* source_dev; + + uint32_t new_password; FuriString* text_box_store; @@ -55,6 +67,7 @@ struct NfcMagic { Popup* popup; Loading* loading; TextInput* text_input; + ByteInput* byte_input; Widget* widget; }; @@ -63,6 +76,7 @@ typedef enum { NfcMagicViewPopup, NfcMagicViewLoading, NfcMagicViewTextInput, + NfcMagicViewByteInput, NfcMagicViewWidget, } NfcMagicView; diff --git a/applications/external/nfc_magic/nfc_magic_worker.c b/applications/external/nfc_magic/nfc_magic_worker.c index 92eb793a71..dc22b5d3ec 100644 --- a/applications/external/nfc_magic/nfc_magic_worker.c +++ b/applications/external/nfc_magic/nfc_magic_worker.c @@ -1,6 +1,9 @@ #include "nfc_magic_worker_i.h" -#include "lib/magic/magic.h" +#include "nfc_magic_i.h" +#include "lib/magic/common.h" +#include "lib/magic/classic_gen1.h" +#include "lib/magic/gen4.h" #define TAG "NfcMagicWorker" @@ -43,15 +46,20 @@ void nfc_magic_worker_stop(NfcMagicWorker* nfc_magic_worker) { void nfc_magic_worker_start( NfcMagicWorker* nfc_magic_worker, NfcMagicWorkerState state, + NfcMagicDevice* magic_dev, NfcDeviceData* dev_data, + uint32_t new_password, NfcMagicWorkerCallback callback, void* context) { furi_assert(nfc_magic_worker); + furi_assert(magic_dev); furi_assert(dev_data); nfc_magic_worker->callback = callback; nfc_magic_worker->context = context; + nfc_magic_worker->magic_dev = magic_dev; nfc_magic_worker->dev_data = dev_data; + nfc_magic_worker->new_password = new_password; nfc_magic_worker_change_state(nfc_magic_worker, state); furi_thread_start(nfc_magic_worker->thread); } @@ -63,6 +71,8 @@ int32_t nfc_magic_worker_task(void* context) { nfc_magic_worker_check(nfc_magic_worker); } else if(nfc_magic_worker->state == NfcMagicWorkerStateWrite) { nfc_magic_worker_write(nfc_magic_worker); + } else if(nfc_magic_worker->state == NfcMagicWorkerStateRekey) { + nfc_magic_worker_rekey(nfc_magic_worker); } else if(nfc_magic_worker->state == NfcMagicWorkerStateWipe) { nfc_magic_worker_wipe(nfc_magic_worker); } @@ -74,59 +84,245 @@ int32_t nfc_magic_worker_task(void* context) { void nfc_magic_worker_write(NfcMagicWorker* nfc_magic_worker) { bool card_found_notified = false; + bool done = false; FuriHalNfcDevData nfc_data = {}; - MfClassicData* src_data = &nfc_magic_worker->dev_data->mf_classic_data; + NfcMagicDevice* magic_dev = nfc_magic_worker->magic_dev; + NfcDeviceData* dev_data = nfc_magic_worker->dev_data; + NfcProtocol dev_protocol = dev_data->protocol; while(nfc_magic_worker->state == NfcMagicWorkerStateWrite) { - if(furi_hal_nfc_detect(&nfc_data, 200)) { - if(!card_found_notified) { - nfc_magic_worker->callback( - NfcMagicWorkerEventCardDetected, nfc_magic_worker->context); - card_found_notified = true; - } - furi_hal_nfc_sleep(); - if(!magic_wupa()) { - FURI_LOG_E(TAG, "No card response to WUPA (not a magic card)"); - nfc_magic_worker->callback( - NfcMagicWorkerEventWrongCard, nfc_magic_worker->context); - break; - } - furi_hal_nfc_sleep(); - } - if(magic_wupa()) { - if(!magic_data_access_cmd()) { - FURI_LOG_E(TAG, "No card response to data access command (not a magic card)"); - nfc_magic_worker->callback( - NfcMagicWorkerEventWrongCard, nfc_magic_worker->context); - break; - } - for(size_t i = 0; i < 64; i++) { - FURI_LOG_D(TAG, "Writing block %d", i); - if(!magic_write_blk(i, &src_data->block[i])) { - FURI_LOG_E(TAG, "Failed to write %d block", i); - nfc_magic_worker->callback(NfcMagicWorkerEventFail, nfc_magic_worker->context); + do { + if(furi_hal_nfc_detect(&nfc_data, 200)) { + if(nfc_data.cuid != magic_dev->cuid) break; + if(!card_found_notified) { + nfc_magic_worker->callback( + NfcMagicWorkerEventCardDetected, nfc_magic_worker->context); + card_found_notified = true; + } + furi_hal_nfc_sleep(); + + magic_activate(); + if(magic_dev->type == MagicTypeClassicGen1) { + if(dev_protocol != NfcDeviceProtocolMifareClassic) break; + MfClassicData* mfc_data = &dev_data->mf_classic_data; + + if(mfc_data->type != MfClassicType1k) break; + if(!magic_gen1_wupa()) { + FURI_LOG_E(TAG, "Not Magic card"); + nfc_magic_worker->callback( + NfcMagicWorkerEventWrongCard, nfc_magic_worker->context); + done = true; + break; + } + if(!magic_gen1_data_access_cmd()) { + FURI_LOG_E(TAG, "Not Magic card"); + nfc_magic_worker->callback( + NfcMagicWorkerEventWrongCard, nfc_magic_worker->context); + done = true; + break; + } + for(size_t i = 0; i < 64; i++) { + FURI_LOG_D(TAG, "Writing block %d", i); + if(!magic_gen1_write_blk(i, &mfc_data->block[i])) { + FURI_LOG_E(TAG, "Failed to write %d block", i); + nfc_magic_worker->callback( + NfcMagicWorkerEventFail, nfc_magic_worker->context); + done = true; + break; + } + } + + nfc_magic_worker->callback( + NfcMagicWorkerEventSuccess, nfc_magic_worker->context); + done = true; + break; + } else if(magic_dev->type == MagicTypeGen4) { + uint8_t gen4_config[28]; + uint32_t password = magic_dev->password; + + uint32_t cuid; + if(dev_protocol == NfcDeviceProtocolMifareClassic) { + gen4_config[0] = 0x00; + gen4_config[27] = 0x00; + } else if(dev_protocol == NfcDeviceProtocolMifareUl) { + MfUltralightData* mf_ul_data = &dev_data->mf_ul_data; + gen4_config[0] = 0x01; + switch(mf_ul_data->type) { + case MfUltralightTypeUL11: + case MfUltralightTypeUL21: + // UL-C? + // UL? + default: + gen4_config[27] = MagicGen4UltralightModeUL_EV1; + break; + case MfUltralightTypeNTAG203: + case MfUltralightTypeNTAG213: + case MfUltralightTypeNTAG215: + case MfUltralightTypeNTAG216: + case MfUltralightTypeNTAGI2C1K: + case MfUltralightTypeNTAGI2C2K: + case MfUltralightTypeNTAGI2CPlus1K: + case MfUltralightTypeNTAGI2CPlus2K: + gen4_config[27] = MagicGen4UltralightModeNTAG; + break; + } + } + + if(dev_data->nfc_data.uid_len == 4) { + gen4_config[1] = MagicGen4UIDLengthSingle; + } else if(dev_data->nfc_data.uid_len == 7) { + gen4_config[1] = MagicGen4UIDLengthDouble; + } else { + FURI_LOG_E(TAG, "Unexpected UID length %d", dev_data->nfc_data.uid_len); + nfc_magic_worker->callback( + NfcMagicWorkerEventFail, nfc_magic_worker->context); + done = true; + break; + } + + gen4_config[2] = (uint8_t)(password >> 24); + gen4_config[3] = (uint8_t)(password >> 16); + gen4_config[4] = (uint8_t)(password >> 8); + gen4_config[5] = (uint8_t)password; + + if(dev_protocol == NfcDeviceProtocolMifareUl) { + gen4_config[6] = MagicGen4ShadowModeHighSpeedIgnore; + } else { + gen4_config[6] = MagicGen4ShadowModeIgnore; + } + gen4_config[7] = 0x00; + memset(gen4_config + 8, 0, 16); + gen4_config[24] = dev_data->nfc_data.atqa[0]; + gen4_config[25] = dev_data->nfc_data.atqa[1]; + gen4_config[26] = dev_data->nfc_data.sak; + + furi_hal_nfc_activate_nfca(200, &cuid); + if(!magic_gen4_set_cfg(password, gen4_config, sizeof(gen4_config), false)) { + nfc_magic_worker->callback( + NfcMagicWorkerEventFail, nfc_magic_worker->context); + done = true; + break; + } + if(dev_protocol == NfcDeviceProtocolMifareClassic) { + MfClassicData* mfc_data = &dev_data->mf_classic_data; + size_t block_count = 64; + if(mfc_data->type == MfClassicType4k) block_count = 256; + for(size_t i = 0; i < block_count; i++) { + FURI_LOG_D(TAG, "Writing block %d", i); + if(!magic_gen4_write_blk(password, i, mfc_data->block[i].value)) { + FURI_LOG_E(TAG, "Failed to write %d block", i); + nfc_magic_worker->callback( + NfcMagicWorkerEventFail, nfc_magic_worker->context); + done = true; + break; + } + } + } else if(dev_protocol == NfcDeviceProtocolMifareUl) { + MfUltralightData* mf_ul_data = &dev_data->mf_ul_data; + for(size_t i = 0; (i * 4) < mf_ul_data->data_read; i++) { + size_t data_offset = i * 4; + FURI_LOG_D( + TAG, + "Writing page %zu (%zu/%u)", + i, + data_offset, + mf_ul_data->data_read); + uint8_t* block = mf_ul_data->data + data_offset; + if(!magic_gen4_write_blk(password, i, block)) { + FURI_LOG_E(TAG, "Failed to write %zu page", i); + nfc_magic_worker->callback( + NfcMagicWorkerEventFail, nfc_magic_worker->context); + done = true; + break; + } + } + + uint8_t buffer[16] = {0}; + + for(size_t i = 0; i < 8; i++) { + memcpy(buffer, &mf_ul_data->signature[i * 4], 4); //-V1086 + if(!magic_gen4_write_blk(password, 0xF2 + i, buffer)) { + FURI_LOG_E(TAG, "Failed to write signature block %d", i); + nfc_magic_worker->callback( + NfcMagicWorkerEventFail, nfc_magic_worker->context); + done = true; + break; + } + } + + buffer[0] = mf_ul_data->version.header; + buffer[1] = mf_ul_data->version.vendor_id; + buffer[2] = mf_ul_data->version.prod_type; + buffer[3] = mf_ul_data->version.prod_subtype; + if(!magic_gen4_write_blk(password, 0xFA, buffer)) { + FURI_LOG_E(TAG, "Failed to write version block 0"); + nfc_magic_worker->callback( + NfcMagicWorkerEventFail, nfc_magic_worker->context); + done = true; + break; + } + + buffer[0] = mf_ul_data->version.prod_ver_major; + buffer[1] = mf_ul_data->version.prod_ver_minor; + buffer[2] = mf_ul_data->version.storage_size; + buffer[3] = mf_ul_data->version.protocol_type; + if(!magic_gen4_write_blk(password, 0xFB, buffer)) { + FURI_LOG_E(TAG, "Failed to write version block 1"); + nfc_magic_worker->callback( + NfcMagicWorkerEventFail, nfc_magic_worker->context); + done = true; + break; + } + } + + nfc_magic_worker->callback( + NfcMagicWorkerEventSuccess, nfc_magic_worker->context); + done = true; break; } } - nfc_magic_worker->callback(NfcMagicWorkerEventSuccess, nfc_magic_worker->context); - break; - } else { - if(card_found_notified) { - nfc_magic_worker->callback( - NfcMagicWorkerEventNoCardDetected, nfc_magic_worker->context); - card_found_notified = false; - } + } while(false); + + if(done) break; + + if(card_found_notified) { + nfc_magic_worker->callback( + NfcMagicWorkerEventNoCardDetected, nfc_magic_worker->context); + card_found_notified = false; } + furi_delay_ms(300); } magic_deactivate(); } void nfc_magic_worker_check(NfcMagicWorker* nfc_magic_worker) { + NfcMagicDevice* magic_dev = nfc_magic_worker->magic_dev; bool card_found_notified = false; + uint8_t gen4_config[MAGIC_GEN4_CONFIG_LEN]; while(nfc_magic_worker->state == NfcMagicWorkerStateCheck) { - if(magic_wupa()) { + magic_activate(); + if(magic_gen1_wupa()) { + magic_dev->type = MagicTypeClassicGen1; + if(!card_found_notified) { + nfc_magic_worker->callback( + NfcMagicWorkerEventCardDetected, nfc_magic_worker->context); + card_found_notified = true; + } + + furi_hal_nfc_activate_nfca(200, &magic_dev->cuid); + nfc_magic_worker->callback(NfcMagicWorkerEventSuccess, nfc_magic_worker->context); + break; + } + + magic_deactivate(); + furi_delay_ms(300); + magic_activate(); + + furi_hal_nfc_activate_nfca(200, &magic_dev->cuid); + if(magic_gen4_get_cfg(magic_dev->password, gen4_config)) { + magic_dev->type = MagicTypeGen4; if(!card_found_notified) { nfc_magic_worker->callback( NfcMagicWorkerEventCardDetected, nfc_magic_worker->context); @@ -135,12 +331,56 @@ void nfc_magic_worker_check(NfcMagicWorker* nfc_magic_worker) { nfc_magic_worker->callback(NfcMagicWorkerEventSuccess, nfc_magic_worker->context); break; - } else { + } + + if(card_found_notified) { + nfc_magic_worker->callback( + NfcMagicWorkerEventNoCardDetected, nfc_magic_worker->context); + card_found_notified = false; + } + + magic_deactivate(); + furi_delay_ms(300); + } + + magic_deactivate(); +} + +void nfc_magic_worker_rekey(NfcMagicWorker* nfc_magic_worker) { + NfcMagicDevice* magic_dev = nfc_magic_worker->magic_dev; + bool card_found_notified = false; + + if(magic_dev->type != MagicTypeGen4) { + nfc_magic_worker->callback(NfcMagicWorkerEventCardDetected, nfc_magic_worker->context); + return; + } + + while(nfc_magic_worker->state == NfcMagicWorkerStateRekey) { + magic_activate(); + uint32_t cuid; + furi_hal_nfc_activate_nfca(200, &cuid); + if(cuid != magic_dev->cuid) { if(card_found_notified) { nfc_magic_worker->callback( NfcMagicWorkerEventNoCardDetected, nfc_magic_worker->context); card_found_notified = false; } + continue; + } + + nfc_magic_worker->callback(NfcMagicWorkerEventCardDetected, nfc_magic_worker->context); + card_found_notified = true; + + if(magic_gen4_set_pwd(magic_dev->password, nfc_magic_worker->new_password)) { + magic_dev->password = nfc_magic_worker->new_password; + nfc_magic_worker->callback(NfcMagicWorkerEventSuccess, nfc_magic_worker->context); + break; + } + + if(card_found_notified) { //-V547 + nfc_magic_worker->callback( + NfcMagicWorkerEventNoCardDetected, nfc_magic_worker->context); + card_found_notified = false; } furi_delay_ms(300); } @@ -148,6 +388,10 @@ void nfc_magic_worker_check(NfcMagicWorker* nfc_magic_worker) { } void nfc_magic_worker_wipe(NfcMagicWorker* nfc_magic_worker) { + NfcMagicDevice* magic_dev = nfc_magic_worker->magic_dev; + bool card_found_notified = false; + bool card_wiped = false; + MfClassicBlock block; memset(&block, 0, sizeof(MfClassicBlock)); block.value[0] = 0x01; @@ -159,14 +403,48 @@ void nfc_magic_worker_wipe(NfcMagicWorker* nfc_magic_worker) { block.value[6] = 0x04; while(nfc_magic_worker->state == NfcMagicWorkerStateWipe) { - magic_deactivate(); - furi_delay_ms(300); - if(!magic_wupa()) continue; - if(!magic_wipe()) continue; - if(!magic_data_access_cmd()) continue; - if(!magic_write_blk(0, &block)) continue; - nfc_magic_worker->callback(NfcMagicWorkerEventSuccess, nfc_magic_worker->context); - break; + do { + magic_deactivate(); + furi_delay_ms(300); + if(!magic_activate()) break; + if(magic_dev->type == MagicTypeClassicGen1) { + if(!magic_gen1_wupa()) break; + if(!card_found_notified) { + nfc_magic_worker->callback( + NfcMagicWorkerEventCardDetected, nfc_magic_worker->context); + card_found_notified = true; + } + + if(!magic_gen1_wipe()) break; + if(!magic_gen1_data_access_cmd()) break; + if(!magic_gen1_write_blk(0, &block)) break; + + card_wiped = true; + nfc_magic_worker->callback(NfcMagicWorkerEventSuccess, nfc_magic_worker->context); + } else if(magic_dev->type == MagicTypeGen4) { + uint32_t cuid; + if(!furi_hal_nfc_activate_nfca(200, &cuid)) break; + if(cuid != magic_dev->cuid) break; + if(!card_found_notified) { + nfc_magic_worker->callback( + NfcMagicWorkerEventCardDetected, nfc_magic_worker->context); + card_found_notified = true; + } + + if(!magic_gen4_wipe(magic_dev->password)) break; + + card_wiped = true; + nfc_magic_worker->callback(NfcMagicWorkerEventSuccess, nfc_magic_worker->context); + } + } while(false); + + if(card_wiped) break; + + if(card_found_notified) { + nfc_magic_worker->callback( + NfcMagicWorkerEventNoCardDetected, nfc_magic_worker->context); + card_found_notified = false; + } } magic_deactivate(); } diff --git a/applications/external/nfc_magic/nfc_magic_worker.h b/applications/external/nfc_magic/nfc_magic_worker.h index 9d29bb3a8b..51ff4ee438 100644 --- a/applications/external/nfc_magic/nfc_magic_worker.h +++ b/applications/external/nfc_magic/nfc_magic_worker.h @@ -1,6 +1,7 @@ #pragma once #include +#include "nfc_magic.h" typedef struct NfcMagicWorker NfcMagicWorker; @@ -9,6 +10,7 @@ typedef enum { NfcMagicWorkerStateCheck, NfcMagicWorkerStateWrite, + NfcMagicWorkerStateRekey, NfcMagicWorkerStateWipe, NfcMagicWorkerStateStop, @@ -33,6 +35,8 @@ void nfc_magic_worker_stop(NfcMagicWorker* nfc_magic_worker); void nfc_magic_worker_start( NfcMagicWorker* nfc_magic_worker, NfcMagicWorkerState state, + NfcMagicDevice* magic_dev, NfcDeviceData* dev_data, + uint32_t new_password, NfcMagicWorkerCallback callback, void* context); diff --git a/applications/external/nfc_magic/nfc_magic_worker_i.h b/applications/external/nfc_magic/nfc_magic_worker_i.h index 0cde2e7125..a354f80476 100644 --- a/applications/external/nfc_magic/nfc_magic_worker_i.h +++ b/applications/external/nfc_magic/nfc_magic_worker_i.h @@ -3,11 +3,14 @@ #include #include "nfc_magic_worker.h" +#include "lib/magic/common.h" struct NfcMagicWorker { FuriThread* thread; + NfcMagicDevice* magic_dev; NfcDeviceData* dev_data; + uint32_t new_password; NfcMagicWorkerCallback callback; void* context; @@ -21,4 +24,6 @@ void nfc_magic_worker_check(NfcMagicWorker* nfc_magic_worker); void nfc_magic_worker_write(NfcMagicWorker* nfc_magic_worker); +void nfc_magic_worker_rekey(NfcMagicWorker* nfc_magic_worker); + void nfc_magic_worker_wipe(NfcMagicWorker* nfc_magic_worker); diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_actions.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_actions.c new file mode 100644 index 0000000000..675262a9b2 --- /dev/null +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_actions.c @@ -0,0 +1,50 @@ +#include "../nfc_magic_i.h" +enum SubmenuIndex { + SubmenuIndexWrite, + SubmenuIndexWipe, +}; + +void nfc_magic_scene_actions_submenu_callback(void* context, uint32_t index) { + NfcMagic* nfc_magic = context; + view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, index); +} + +void nfc_magic_scene_actions_on_enter(void* context) { + NfcMagic* nfc_magic = context; + + Submenu* submenu = nfc_magic->submenu; + submenu_add_item( + submenu, "Write", SubmenuIndexWrite, nfc_magic_scene_actions_submenu_callback, nfc_magic); + submenu_add_item( + submenu, "Wipe", SubmenuIndexWipe, nfc_magic_scene_actions_submenu_callback, nfc_magic); + + submenu_set_selected_item( + submenu, scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneActions)); + view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewMenu); +} + +bool nfc_magic_scene_actions_on_event(void* context, SceneManagerEvent event) { + NfcMagic* nfc_magic = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubmenuIndexWrite) { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneFileSelect); + consumed = true; + } else if(event.event == SubmenuIndexWipe) { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWipe); + consumed = true; + } + scene_manager_set_scene_state(nfc_magic->scene_manager, NfcMagicSceneActions, event.event); + } else if(event.type == SceneManagerEventTypeBack) { + consumed = scene_manager_search_and_switch_to_previous_scene( + nfc_magic->scene_manager, NfcMagicSceneStart); + } + + return consumed; +} + +void nfc_magic_scene_actions_on_exit(void* context) { + NfcMagic* nfc_magic = context; + submenu_reset(nfc_magic->submenu); +} diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_check.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_check.c index d517972428..90b43d7d3a 100644 --- a/applications/external/nfc_magic/scenes/nfc_magic_scene_check.c +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_check.c @@ -42,7 +42,9 @@ void nfc_magic_scene_check_on_enter(void* context) { nfc_magic_worker_start( nfc_magic->worker, NfcMagicWorkerStateCheck, - &nfc_magic->nfc_dev->dev_data, + nfc_magic->dev, + &nfc_magic->source_dev->dev_data, + nfc_magic->new_password, nfc_magic_check_worker_callback, nfc_magic); nfc_magic_blink_start(nfc_magic); diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_config.h b/applications/external/nfc_magic/scenes/nfc_magic_scene_config.h index 557e26914e..2f9860d96f 100644 --- a/applications/external/nfc_magic/scenes/nfc_magic_scene_config.h +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_config.h @@ -1,4 +1,8 @@ ADD_SCENE(nfc_magic, start, Start) +ADD_SCENE(nfc_magic, key_input, KeyInput) +ADD_SCENE(nfc_magic, actions, Actions) +ADD_SCENE(nfc_magic, gen4_actions, Gen4Actions) +ADD_SCENE(nfc_magic, new_key_input, NewKeyInput) ADD_SCENE(nfc_magic, file_select, FileSelect) ADD_SCENE(nfc_magic, write_confirm, WriteConfirm) ADD_SCENE(nfc_magic, wrong_card, WrongCard) @@ -8,5 +12,7 @@ ADD_SCENE(nfc_magic, success, Success) ADD_SCENE(nfc_magic, check, Check) ADD_SCENE(nfc_magic, not_magic, NotMagic) ADD_SCENE(nfc_magic, magic_info, MagicInfo) +ADD_SCENE(nfc_magic, rekey, Rekey) +ADD_SCENE(nfc_magic, rekey_fail, RekeyFail) ADD_SCENE(nfc_magic, wipe, Wipe) ADD_SCENE(nfc_magic, wipe_fail, WipeFail) diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_file_select.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_file_select.c index d78422eeb6..baa6bcccc2 100644 --- a/applications/external/nfc_magic/scenes/nfc_magic_scene_file_select.c +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_file_select.c @@ -1,22 +1,60 @@ #include "../nfc_magic_i.h" -static bool nfc_magic_scene_file_select_is_file_suitable(NfcDevice* nfc_dev) { - return (nfc_dev->format == NfcDeviceSaveFormatMifareClassic) && - (nfc_dev->dev_data.mf_classic_data.type == MfClassicType1k) && - (nfc_dev->dev_data.nfc_data.uid_len == 4); +static bool nfc_magic_scene_file_select_is_file_suitable(NfcMagic* nfc_magic) { + NfcDevice* nfc_dev = nfc_magic->source_dev; + if(nfc_dev->format == NfcDeviceSaveFormatMifareClassic) { + switch(nfc_magic->dev->type) { + case MagicTypeClassicGen1: + case MagicTypeClassicDirectWrite: + case MagicTypeClassicAPDU: + if((nfc_dev->dev_data.mf_classic_data.type != MfClassicType1k) || + (nfc_dev->dev_data.nfc_data.uid_len != 4)) { + return false; + } + return true; + + case MagicTypeGen4: + return true; + default: + return false; + } + } else if( + (nfc_dev->format == NfcDeviceSaveFormatMifareUl) && + (nfc_dev->dev_data.nfc_data.uid_len == 7)) { + switch(nfc_magic->dev->type) { + case MagicTypeUltralightGen1: + case MagicTypeUltralightDirectWrite: + case MagicTypeUltralightC_Gen1: + case MagicTypeUltralightC_DirectWrite: + case MagicTypeGen4: + switch(nfc_dev->dev_data.mf_ul_data.type) { + case MfUltralightTypeNTAGI2C1K: + case MfUltralightTypeNTAGI2C2K: + case MfUltralightTypeNTAGI2CPlus1K: + case MfUltralightTypeNTAGI2CPlus2K: + return false; + default: + return true; + } + default: + return false; + } + } + + return false; } void nfc_magic_scene_file_select_on_enter(void* context) { NfcMagic* nfc_magic = context; // Process file_select return - nfc_device_set_loading_callback(nfc_magic->nfc_dev, nfc_magic_show_loading_popup, nfc_magic); + nfc_device_set_loading_callback( + nfc_magic->source_dev, nfc_magic_show_loading_popup, nfc_magic); - if(!furi_string_size(nfc_magic->nfc_dev->load_path)) { - furi_string_set_str(nfc_magic->nfc_dev->load_path, NFC_APP_FOLDER); + if(!furi_string_size(nfc_magic->source_dev->load_path)) { + furi_string_set_str(nfc_magic->source_dev->load_path, NFC_APP_FOLDER); } - - if(nfc_file_select(nfc_magic->nfc_dev)) { - if(nfc_magic_scene_file_select_is_file_suitable(nfc_magic->nfc_dev)) { + if(nfc_file_select(nfc_magic->source_dev)) { + if(nfc_magic_scene_file_select_is_file_suitable(nfc_magic)) { scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWriteConfirm); } else { scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWrongCard); @@ -34,5 +72,5 @@ bool nfc_magic_scene_file_select_on_event(void* context, SceneManagerEvent event void nfc_magic_scene_file_select_on_exit(void* context) { NfcMagic* nfc_magic = context; - nfc_device_set_loading_callback(nfc_magic->nfc_dev, NULL, nfc_magic); + nfc_device_set_loading_callback(nfc_magic->source_dev, NULL, nfc_magic); } diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_gen4_actions.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_gen4_actions.c new file mode 100644 index 0000000000..ceaa33e29f --- /dev/null +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_gen4_actions.c @@ -0,0 +1,70 @@ +#include "../nfc_magic_i.h" +enum SubmenuIndex { + SubmenuIndexWrite, + SubmenuIndexChangePassword, + SubmenuIndexWipe, +}; + +void nfc_magic_scene_gen4_actions_submenu_callback(void* context, uint32_t index) { + NfcMagic* nfc_magic = context; + view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, index); +} + +void nfc_magic_scene_gen4_actions_on_enter(void* context) { + NfcMagic* nfc_magic = context; + + Submenu* submenu = nfc_magic->submenu; + submenu_add_item( + submenu, + "Write", + SubmenuIndexWrite, + nfc_magic_scene_gen4_actions_submenu_callback, + nfc_magic); + submenu_add_item( + submenu, + "Change password", + SubmenuIndexChangePassword, + nfc_magic_scene_gen4_actions_submenu_callback, + nfc_magic); + submenu_add_item( + submenu, + "Wipe", + SubmenuIndexWipe, + nfc_magic_scene_gen4_actions_submenu_callback, + nfc_magic); + + submenu_set_selected_item( + submenu, + scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneGen4Actions)); + view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewMenu); +} + +bool nfc_magic_scene_gen4_actions_on_event(void* context, SceneManagerEvent event) { + NfcMagic* nfc_magic = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubmenuIndexWrite) { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneFileSelect); + consumed = true; + } else if(event.event == SubmenuIndexChangePassword) { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneNewKeyInput); + consumed = true; + } else if(event.event == SubmenuIndexWipe) { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWipe); + consumed = true; + } + scene_manager_set_scene_state( + nfc_magic->scene_manager, NfcMagicSceneGen4Actions, event.event); + } else if(event.type == SceneManagerEventTypeBack) { + consumed = scene_manager_search_and_switch_to_previous_scene( + nfc_magic->scene_manager, NfcMagicSceneStart); + } + + return consumed; +} + +void nfc_magic_scene_gen4_actions_on_exit(void* context) { + NfcMagic* nfc_magic = context; + submenu_reset(nfc_magic->submenu); +} diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_key_input.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_key_input.c new file mode 100644 index 0000000000..58b487a09b --- /dev/null +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_key_input.c @@ -0,0 +1,45 @@ +#include "../nfc_magic_i.h" + +void nfc_magic_scene_key_input_byte_input_callback(void* context) { + NfcMagic* nfc_magic = context; + + view_dispatcher_send_custom_event( + nfc_magic->view_dispatcher, NfcMagicCustomEventByteInputDone); +} + +void nfc_magic_scene_key_input_on_enter(void* context) { + NfcMagic* nfc_magic = context; + + // Setup view + ByteInput* byte_input = nfc_magic->byte_input; + byte_input_set_header_text(byte_input, "Enter the password in hex"); + byte_input_set_result_callback( + byte_input, + nfc_magic_scene_key_input_byte_input_callback, + NULL, + nfc_magic, + (uint8_t*)&nfc_magic->dev->password, + 4); + view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewByteInput); +} + +bool nfc_magic_scene_key_input_on_event(void* context, SceneManagerEvent event) { + NfcMagic* nfc_magic = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == NfcMagicCustomEventByteInputDone) { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneCheck); + consumed = true; + } + } + return consumed; +} + +void nfc_magic_scene_key_input_on_exit(void* context) { + NfcMagic* nfc_magic = context; + + // Clear view + byte_input_set_result_callback(nfc_magic->byte_input, NULL, NULL, NULL, NULL, 0); + byte_input_set_header_text(nfc_magic->byte_input, ""); +} diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_magic_info.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_magic_info.c index e9b226b3ab..c147ac4383 100644 --- a/applications/external/nfc_magic/scenes/nfc_magic_scene_magic_info.c +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_magic_info.c @@ -1,4 +1,5 @@ #include "../nfc_magic_i.h" +#include "../lib/magic/types.h" void nfc_magic_scene_magic_info_widget_callback( GuiButtonType result, @@ -13,14 +14,18 @@ void nfc_magic_scene_magic_info_widget_callback( void nfc_magic_scene_magic_info_on_enter(void* context) { NfcMagic* nfc_magic = context; Widget* widget = nfc_magic->widget; + const char* card_type = nfc_magic_type(nfc_magic->dev->type); notification_message(nfc_magic->notifications, &sequence_success); widget_add_icon_element(widget, 73, 17, &I_DolphinCommon_56x48); widget_add_string_element( widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "Magic card detected"); + widget_add_string_element(widget, 3, 17, AlignLeft, AlignTop, FontSecondary, card_type); widget_add_button_element( widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_magic_info_widget_callback, nfc_magic); + widget_add_button_element( + widget, GuiButtonTypeRight, "More", nfc_magic_scene_magic_info_widget_callback, nfc_magic); // Setup and start worker view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget); @@ -33,6 +38,15 @@ bool nfc_magic_scene_magic_info_on_event(void* context, SceneManagerEvent event) if(event.type == SceneManagerEventTypeCustom) { if(event.event == GuiButtonTypeLeft) { consumed = scene_manager_previous_scene(nfc_magic->scene_manager); + } else if(event.event == GuiButtonTypeRight) { + MagicType type = nfc_magic->dev->type; + if(type == MagicTypeGen4) { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneGen4Actions); + consumed = true; + } else { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneActions); + consumed = true; + } } } return consumed; diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_new_key_input.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_new_key_input.c new file mode 100644 index 0000000000..b5247f6c55 --- /dev/null +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_new_key_input.c @@ -0,0 +1,45 @@ +#include "../nfc_magic_i.h" + +void nfc_magic_scene_new_key_input_byte_input_callback(void* context) { + NfcMagic* nfc_magic = context; + + view_dispatcher_send_custom_event( + nfc_magic->view_dispatcher, NfcMagicCustomEventByteInputDone); +} + +void nfc_magic_scene_new_key_input_on_enter(void* context) { + NfcMagic* nfc_magic = context; + + // Setup view + ByteInput* byte_input = nfc_magic->byte_input; + byte_input_set_header_text(byte_input, "Enter the password in hex"); + byte_input_set_result_callback( + byte_input, + nfc_magic_scene_new_key_input_byte_input_callback, + NULL, + nfc_magic, + (uint8_t*)&nfc_magic->new_password, + 4); + view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewByteInput); +} + +bool nfc_magic_scene_new_key_input_on_event(void* context, SceneManagerEvent event) { + NfcMagic* nfc_magic = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == NfcMagicCustomEventByteInputDone) { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneRekey); + consumed = true; + } + } + return consumed; +} + +void nfc_magic_scene_new_key_input_on_exit(void* context) { + NfcMagic* nfc_magic = context; + + // Clear view + byte_input_set_result_callback(nfc_magic->byte_input, NULL, NULL, NULL, NULL, 0); + byte_input_set_header_text(nfc_magic->byte_input, ""); +} diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_rekey.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_rekey.c new file mode 100644 index 0000000000..259dc78eaa --- /dev/null +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_rekey.c @@ -0,0 +1,95 @@ +#include "../nfc_magic_i.h" + +enum { + NfcMagicSceneRekeyStateCardSearch, + NfcMagicSceneRekeyStateCardFound, +}; + +bool nfc_magic_rekey_worker_callback(NfcMagicWorkerEvent event, void* context) { + furi_assert(context); + + NfcMagic* nfc_magic = context; + view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, event); + + return true; +} + +static void nfc_magic_scene_rekey_setup_view(NfcMagic* nfc_magic) { + Popup* popup = nfc_magic->popup; + popup_reset(popup); + uint32_t state = scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneRekey); + + if(state == NfcMagicSceneRekeyStateCardSearch) { + popup_set_text( + nfc_magic->popup, + "Apply the\nsame card\nto the back", + 128, + 32, + AlignRight, + AlignCenter); + popup_set_icon(nfc_magic->popup, 0, 8, &I_NFC_manual_60x50); + } else { + popup_set_icon(popup, 12, 23, &I_Loading_24); + popup_set_header(popup, "Writing\nDon't move...", 52, 32, AlignLeft, AlignCenter); + } + + view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewPopup); +} + +void nfc_magic_scene_rekey_on_enter(void* context) { + NfcMagic* nfc_magic = context; + + scene_manager_set_scene_state( + nfc_magic->scene_manager, NfcMagicSceneRekey, NfcMagicSceneRekeyStateCardSearch); + nfc_magic_scene_rekey_setup_view(nfc_magic); + + // Setup and start worker + nfc_magic_worker_start( + nfc_magic->worker, + NfcMagicWorkerStateRekey, + nfc_magic->dev, + &nfc_magic->source_dev->dev_data, + nfc_magic->new_password, + nfc_magic_rekey_worker_callback, + nfc_magic); + nfc_magic_blink_start(nfc_magic); +} + +bool nfc_magic_scene_rekey_on_event(void* context, SceneManagerEvent event) { + NfcMagic* nfc_magic = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == NfcMagicWorkerEventSuccess) { + nfc_magic->dev->password = nfc_magic->new_password; + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneSuccess); + consumed = true; + } else if(event.event == NfcMagicWorkerEventFail) { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneRekeyFail); + consumed = true; + } else if(event.event == NfcMagicWorkerEventCardDetected) { + scene_manager_set_scene_state( + nfc_magic->scene_manager, NfcMagicSceneRekey, NfcMagicSceneRekeyStateCardFound); + nfc_magic_scene_rekey_setup_view(nfc_magic); + consumed = true; + } else if(event.event == NfcMagicWorkerEventNoCardDetected) { + scene_manager_set_scene_state( + nfc_magic->scene_manager, NfcMagicSceneRekey, NfcMagicSceneRekeyStateCardSearch); + nfc_magic_scene_rekey_setup_view(nfc_magic); + consumed = true; + } + } + return consumed; +} + +void nfc_magic_scene_rekey_on_exit(void* context) { + NfcMagic* nfc_magic = context; + + nfc_magic_worker_stop(nfc_magic->worker); + scene_manager_set_scene_state( + nfc_magic->scene_manager, NfcMagicSceneRekey, NfcMagicSceneRekeyStateCardSearch); + // Clear view + popup_reset(nfc_magic->popup); + + nfc_magic_blink_stop(nfc_magic); +} diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_rekey_fail.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_rekey_fail.c new file mode 100644 index 0000000000..d30ee57bcf --- /dev/null +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_rekey_fail.c @@ -0,0 +1,50 @@ +#include "../nfc_magic_i.h" + +void nfc_magic_scene_rekey_fail_widget_callback( + GuiButtonType result, + InputType type, + void* context) { + NfcMagic* nfc_magic = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, result); + } +} + +void nfc_magic_scene_rekey_fail_on_enter(void* context) { + NfcMagic* nfc_magic = context; + Widget* widget = nfc_magic->widget; + + notification_message(nfc_magic->notifications, &sequence_error); + + widget_add_icon_element(widget, 72, 17, &I_DolphinCommon_56x48); + widget_add_string_element( + widget, 7, 4, AlignLeft, AlignTop, FontPrimary, "Can't change password!"); + + widget_add_button_element( + widget, GuiButtonTypeLeft, "Finish", nfc_magic_scene_rekey_fail_widget_callback, nfc_magic); + + // Setup and start worker + view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget); +} + +bool nfc_magic_scene_rekey_fail_on_event(void* context, SceneManagerEvent event) { + NfcMagic* nfc_magic = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeLeft) { + consumed = scene_manager_search_and_switch_to_previous_scene( + nfc_magic->scene_manager, NfcMagicSceneStart); + } + } else if(event.type == SceneManagerEventTypeBack) { + consumed = scene_manager_search_and_switch_to_previous_scene( + nfc_magic->scene_manager, NfcMagicSceneStart); + } + return consumed; +} + +void nfc_magic_scene_rekey_fail_on_exit(void* context) { + NfcMagic* nfc_magic = context; + + widget_reset(nfc_magic->widget); +} diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_start.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_start.c index a70eb8accf..b5861629e4 100644 --- a/applications/external/nfc_magic/scenes/nfc_magic_scene_start.c +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_start.c @@ -1,8 +1,7 @@ #include "../nfc_magic_i.h" enum SubmenuIndex { SubmenuIndexCheck, - SubmenuIndexWriteGen1A, - SubmenuIndexWipe, + SubmenuIndexAuthenticateGen4, }; void nfc_magic_scene_start_submenu_callback(void* context, uint32_t index) { @@ -22,12 +21,10 @@ void nfc_magic_scene_start_on_enter(void* context) { nfc_magic); submenu_add_item( submenu, - "Write Gen1A", - SubmenuIndexWriteGen1A, + "Authenticate Gen4", + SubmenuIndexAuthenticateGen4, nfc_magic_scene_start_submenu_callback, nfc_magic); - submenu_add_item( - submenu, "Wipe", SubmenuIndexWipe, nfc_magic_scene_start_submenu_callback, nfc_magic); submenu_set_selected_item( submenu, scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneStart)); @@ -40,23 +37,13 @@ bool nfc_magic_scene_start_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { if(event.event == SubmenuIndexCheck) { + nfc_magic->dev->password = MAGIC_GEN4_DEFAULT_PWD; scene_manager_set_scene_state( nfc_magic->scene_manager, NfcMagicSceneStart, SubmenuIndexCheck); scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneCheck); consumed = true; - } else if(event.event == SubmenuIndexWriteGen1A) { - // Explicitly save state in each branch so that the - // correct option is reselected if the user cancels - // loading a file. - scene_manager_set_scene_state( - nfc_magic->scene_manager, NfcMagicSceneStart, SubmenuIndexWriteGen1A); - scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneFileSelect); - consumed = true; - } else if(event.event == SubmenuIndexWipe) { - scene_manager_set_scene_state( - nfc_magic->scene_manager, NfcMagicSceneStart, SubmenuIndexWipe); - scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWipe); - consumed = true; + } else if(event.event == SubmenuIndexAuthenticateGen4) { + scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneKeyInput); } } diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_wipe.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_wipe.c index 1ca194286a..29640f89c6 100644 --- a/applications/external/nfc_magic/scenes/nfc_magic_scene_wipe.c +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_wipe.c @@ -22,7 +22,12 @@ static void nfc_magic_scene_wipe_setup_view(NfcMagic* nfc_magic) { if(state == NfcMagicSceneWipeStateCardSearch) { popup_set_icon(nfc_magic->popup, 0, 8, &I_NFC_manual_60x50); popup_set_text( - nfc_magic->popup, "Apply card to\nthe back", 128, 32, AlignRight, AlignCenter); + nfc_magic->popup, + "Apply the\nsame card\nto the back", + 128, + 32, + AlignRight, + AlignCenter); } else { popup_set_icon(popup, 12, 23, &I_Loading_24); popup_set_header(popup, "Wiping\nDon't move...", 52, 32, AlignLeft, AlignCenter); @@ -42,7 +47,9 @@ void nfc_magic_scene_wipe_on_enter(void* context) { nfc_magic_worker_start( nfc_magic->worker, NfcMagicWorkerStateWipe, - &nfc_magic->nfc_dev->dev_data, + nfc_magic->dev, + &nfc_magic->source_dev->dev_data, + nfc_magic->new_password, nfc_magic_wipe_worker_callback, nfc_magic); nfc_magic_blink_start(nfc_magic); diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_write.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_write.c index c3e6f962a3..45c54557f1 100644 --- a/applications/external/nfc_magic/scenes/nfc_magic_scene_write.c +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_write.c @@ -21,7 +21,12 @@ static void nfc_magic_scene_write_setup_view(NfcMagic* nfc_magic) { if(state == NfcMagicSceneWriteStateCardSearch) { popup_set_text( - nfc_magic->popup, "Apply card to\nthe back", 128, 32, AlignRight, AlignCenter); + nfc_magic->popup, + "Apply the\nsame card\nto the back", + 128, + 32, + AlignRight, + AlignCenter); popup_set_icon(nfc_magic->popup, 0, 8, &I_NFC_manual_60x50); } else { popup_set_icon(popup, 12, 23, &I_Loading_24); @@ -42,7 +47,9 @@ void nfc_magic_scene_write_on_enter(void* context) { nfc_magic_worker_start( nfc_magic->worker, NfcMagicWorkerStateWrite, - &nfc_magic->nfc_dev->dev_data, + nfc_magic->dev, + &nfc_magic->source_dev->dev_data, + nfc_magic->new_password, nfc_magic_write_worker_callback, nfc_magic); nfc_magic_blink_start(nfc_magic); diff --git a/applications/external/nfc_magic/scenes/nfc_magic_scene_wrong_card.c b/applications/external/nfc_magic/scenes/nfc_magic_scene_wrong_card.c index 4b80896932..857d50c1f7 100644 --- a/applications/external/nfc_magic/scenes/nfc_magic_scene_wrong_card.c +++ b/applications/external/nfc_magic/scenes/nfc_magic_scene_wrong_card.c @@ -26,7 +26,7 @@ void nfc_magic_scene_wrong_card_on_enter(void* context) { AlignLeft, AlignTop, FontSecondary, - "Writing is supported\nonly for 4 bytes UID\nMifare Classic 1k"); + "Writing this file is\nnot supported for\nthis magic card."); widget_add_button_element( widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_wrong_card_widget_callback, nfc_magic); From 12f9b6a89e8a57b818c7139fb3ebb77ee0ac8a4e Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 26 May 2023 13:13:46 +0300 Subject: [PATCH 68/92] Apply desktop favourite apps refactoring --- .../services/desktop/desktop_settings.h | 2 - .../desktop/scenes/desktop_scene_main.c | 115 +++++-------- .../scenes/desktop_settings_scene_favorite.c | 162 ++++++++---------- 3 files changed, 109 insertions(+), 170 deletions(-) diff --git a/applications/services/desktop/desktop_settings.h b/applications/services/desktop/desktop_settings.h index fb63f26f5f..5946873f00 100644 --- a/applications/services/desktop/desktop_settings.h +++ b/applications/services/desktop/desktop_settings.h @@ -43,8 +43,6 @@ #define DISPLAY_BATTERY_RETRO_5 4 #define DISPLAY_BATTERY_BAR_PERCENT 5 -#define FAP_LOADER_APP_NAME "Applications" - typedef struct { InputKey data[MAX_PIN_SIZE]; uint8_t length; diff --git a/applications/services/desktop/scenes/desktop_scene_main.c b/applications/services/desktop/scenes/desktop_scene_main.c index f504646bf4..79f17fee7f 100644 --- a/applications/services/desktop/scenes/desktop_scene_main.c +++ b/applications/services/desktop/scenes/desktop_scene_main.c @@ -12,6 +12,8 @@ #define TAG "DesktopSrv" +#define FAP_LOADER_APP_NAME "Applications" + static void desktop_scene_main_new_idle_animation_callback(void* context) { furi_assert(context); Desktop* desktop = context; @@ -60,6 +62,34 @@ static void desktop_switch_to_app(Desktop* desktop, const FlipperApplication* fl } #endif +static void desktop_scene_main_open_app_or_profile(Desktop* desktop, const char* path) { + do { + LoaderStatus status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, path); + if(status == LoaderStatusOk) break; + FURI_LOG_E(TAG, "loader_start failed: %d", status); + + status = loader_start(desktop->loader, "Passport", NULL); + if(status != LoaderStatusOk) { + FURI_LOG_E(TAG, "loader_start failed: %d", status); + } + } while(false); +} + +static void desktop_scene_main_start_favorite(Desktop* desktop, FavoriteApp* application) { + LoaderStatus status = LoaderStatusErrorInternal; + if(application->is_external) { + status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, application->name_or_path); + } else if(strlen(application->name_or_path) > 0) { + status = loader_start(desktop->loader, application->name_or_path, NULL); + } else { + status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, NULL); + } + + if(status != LoaderStatusOk) { + FURI_LOG_E(TAG, "loader_start failed: %d", status); + } +} + void desktop_scene_main_callback(DesktopEvent event, void* context) { Desktop* desktop = (Desktop*)context; if(desktop->in_transition) return; @@ -130,59 +160,17 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) { case DesktopMainEventOpenFavoritePrimary: DESKTOP_SETTINGS_LOAD(&desktop->settings); - if(desktop->settings.favorite_primary.is_external) { - LoaderStatus status = loader_start( - desktop->loader, - FAP_LOADER_APP_NAME, - desktop->settings.favorite_primary.name_or_path); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } - } else { - LoaderStatus status = loader_start( - desktop->loader, desktop->settings.favorite_primary.name_or_path, NULL); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } - } + desktop_scene_main_start_favorite(desktop, &desktop->settings.favorite_primary); consumed = true; break; case DesktopMainEventOpenFavoriteSecondary: DESKTOP_SETTINGS_LOAD(&desktop->settings); - if(desktop->settings.favorite_secondary.is_external) { - LoaderStatus status = loader_start( - desktop->loader, - FAP_LOADER_APP_NAME, - desktop->settings.favorite_secondary.name_or_path); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } - } else { - LoaderStatus status = loader_start( - desktop->loader, desktop->settings.favorite_secondary.name_or_path, NULL); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } - } + desktop_scene_main_start_favorite(desktop, &desktop->settings.favorite_secondary); consumed = true; break; case DesktopMainEventOpenFavoriteTertiary: DESKTOP_SETTINGS_LOAD(&desktop->settings); - if(desktop->settings.favorite_tertiary.is_external) { - LoaderStatus status = loader_start( - desktop->loader, - FAP_LOADER_APP_NAME, - desktop->settings.favorite_tertiary.name_or_path); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } - } else { - LoaderStatus status = loader_start( - desktop->loader, desktop->settings.favorite_tertiary.name_or_path, NULL); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } - } + desktop_scene_main_start_favorite(desktop, &desktop->settings.favorite_tertiary); consumed = true; break; case DesktopAnimationEventCheckAnimation: @@ -210,51 +198,28 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) { break; } case DesktopMainEventOpenGameMenu: { - LoaderStatus status = loader_start( - desktop->loader, FAP_LOADER_APP_NAME, EXT_PATH("/apps/Games/Snake.fap")); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } + desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Games/Snake.fap")); break; } case DesktopMainEventOpenTetris: { - LoaderStatus status = loader_start( - desktop->loader, FAP_LOADER_APP_NAME, EXT_PATH("/apps/Games/Tetris.fap")); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } + desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Games/Tetris.fap")); break; } case DesktopMainEventOpenArkanoid: { - LoaderStatus status = loader_start( - desktop->loader, FAP_LOADER_APP_NAME, EXT_PATH("/apps/Games/Arkanoid.fap")); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } + desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Games/Arkanoid.fap")); break; } case DesktopMainEventOpenDOOM: { - LoaderStatus status = loader_start( - desktop->loader, FAP_LOADER_APP_NAME, EXT_PATH("/apps/Games/DOOM.fap")); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } + desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Games/DOOM.fap")); break; } case DesktopMainEventOpenZombiez: { - LoaderStatus status = loader_start( - desktop->loader, FAP_LOADER_APP_NAME, EXT_PATH("/apps/Games/Zombiez.fap")); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } + desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Games/Zombiez.fap")); break; } case DesktopMainEventOpenHeap: { - LoaderStatus status = loader_start( - desktop->loader, FAP_LOADER_APP_NAME, EXT_PATH("/apps/Games/heap_defence.fap")); - if(status != LoaderStatusOk) { - FURI_LOG_E(TAG, "loader_start failed: %d", status); - } + desktop_scene_main_open_app_or_profile( + desktop, EXT_PATH("/apps/Games/heap_defence.fap")); break; } case DesktopLockedEventUpdate: diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c index c014c97f78..25bab6dd61 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c @@ -5,6 +5,9 @@ #include #include +#define EXTERNAL_APPLICATION_NAME ("[External Application]") +#define EXTERNAL_APPLICATION_INDEX (FLIPPER_APPS_COUNT + 1) + static bool favorite_fap_selector_item_callback( FuriString* file_path, void* context, @@ -44,6 +47,20 @@ void desktop_settings_scene_favorite_on_enter(void* context) { uint32_t primary_favorite = scene_manager_get_scene_state(app->scene_manager, DesktopSettingsAppSceneFavorite); uint32_t pre_select_item = 0; + FavoriteApp* curr_favorite_app = NULL; + if(primary_favorite == 0) { + curr_favorite_app = &app->settings.favorite_primary; + } else if(primary_favorite == 1) { + curr_favorite_app = &app->settings.favorite_secondary; + } else if(primary_favorite == 2) { + curr_favorite_app = &app->settings.favorite_tertiary; + } else { + curr_favorite_app = &app->settings.favorite_primary; + } + if(curr_favorite_app == NULL) { + // This should not happen! + return; + } for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) { submenu_add_item( @@ -53,30 +70,29 @@ void desktop_settings_scene_favorite_on_enter(void* context) { desktop_settings_scene_favorite_submenu_callback, app); - if(primary_favorite == 0) { // Select favorite item in submenu - if((app->settings.favorite_primary.is_external && - !strcmp(FLIPPER_APPS[i].name, FAP_LOADER_APP_NAME)) || - (!strcmp(FLIPPER_APPS[i].name, app->settings.favorite_primary.name_or_path))) { - pre_select_item = i; - } - } else if(primary_favorite == 1) { - if((app->settings.favorite_secondary.is_external && - !strcmp(FLIPPER_APPS[i].name, FAP_LOADER_APP_NAME)) || - (!strcmp(FLIPPER_APPS[i].name, app->settings.favorite_secondary.name_or_path))) { - pre_select_item = i; - } - } else if(primary_favorite == 2) { - if((app->settings.favorite_tertiary.is_external && - !strcmp(FLIPPER_APPS[i].name, FAP_LOADER_APP_NAME)) || - (!strcmp(FLIPPER_APPS[i].name, app->settings.favorite_tertiary.name_or_path))) { - pre_select_item = i; - } + // Select favorite item in submenu + if(!curr_favorite_app->is_external && + !strcmp(FLIPPER_APPS[i].name, curr_favorite_app->name_or_path)) { + pre_select_item = i; } } + +#ifdef APP_FAP_LOADER + submenu_add_item( + submenu, + EXTERNAL_APPLICATION_NAME, + EXTERNAL_APPLICATION_INDEX, + desktop_settings_scene_favorite_submenu_callback, + app); + if(curr_favorite_app->is_external) { + pre_select_item = EXTERNAL_APPLICATION_INDEX; + } +#endif + submenu_add_item( submenu, "None (disable)", - FLIPPER_APPS_COUNT + 1, + FLIPPER_APPS_COUNT + 2, desktop_settings_scene_favorite_submenu_callback, app); @@ -99,46 +115,24 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e uint32_t primary_favorite = scene_manager_get_scene_state(app->scene_manager, DesktopSettingsAppSceneFavorite); + FavoriteApp* curr_favorite_app = NULL; + if(primary_favorite == 0) { + curr_favorite_app = &app->settings.favorite_primary; + } else if(primary_favorite == 1) { + curr_favorite_app = &app->settings.favorite_secondary; + } else if(primary_favorite == 2) { + curr_favorite_app = &app->settings.favorite_tertiary; + } else { + curr_favorite_app = &app->settings.favorite_primary; + } + if(curr_favorite_app == NULL) { + // This should not happen! + furi_string_free(temp_path); + return consumed; + } if(event.type == SceneManagerEventTypeCustom) { - if(event.event >= (FLIPPER_APPS_COUNT + 1)) { - if(primary_favorite == 0) { - app->settings.favorite_primary.is_external = false; - strncpy(app->settings.favorite_primary.name_or_path, "", MAX_APP_LENGTH); - } else if(primary_favorite == 1) { - app->settings.favorite_secondary.is_external = false; - strncpy(app->settings.favorite_secondary.name_or_path, "", MAX_APP_LENGTH); - } else if(primary_favorite == 2) { - app->settings.favorite_tertiary.is_external = false; - strncpy(app->settings.favorite_tertiary.name_or_path, "", MAX_APP_LENGTH); - } - - scene_manager_previous_scene(app->scene_manager); - consumed = true; - furi_string_free(temp_path); - return consumed; - } - if(strcmp(FLIPPER_APPS[event.event].name, FAP_LOADER_APP_NAME) != 0) { - if(primary_favorite == 0) { - app->settings.favorite_primary.is_external = false; - strncpy( - app->settings.favorite_primary.name_or_path, - FLIPPER_APPS[event.event].name, - MAX_APP_LENGTH); - } else if(primary_favorite == 1) { - app->settings.favorite_secondary.is_external = false; - strncpy( - app->settings.favorite_secondary.name_or_path, - FLIPPER_APPS[event.event].name, - MAX_APP_LENGTH); - } else if(primary_favorite == 2) { - app->settings.favorite_tertiary.is_external = false; - strncpy( - app->settings.favorite_tertiary.name_or_path, - FLIPPER_APPS[event.event].name, - MAX_APP_LENGTH); - } - } else { + if(event.event == EXTERNAL_APPLICATION_INDEX) { const DialogsFileBrowserOptions browser_options = { .extension = ".fap", .icon = &I_unknown_10px, @@ -149,47 +143,29 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e .base_path = EXT_PATH("apps"), }; - if(primary_favorite == 0) { // Select favorite fap in file browser - if(favorite_fap_selector_file_exists( - app->settings.favorite_primary.name_or_path)) { - furi_string_set_str(temp_path, app->settings.favorite_primary.name_or_path); - } - } else if(primary_favorite == 1) { - if(favorite_fap_selector_file_exists( - app->settings.favorite_secondary.name_or_path)) { - furi_string_set_str(temp_path, app->settings.favorite_secondary.name_or_path); - } - } else if(primary_favorite == 2) { - if(favorite_fap_selector_file_exists( - app->settings.favorite_tertiary.name_or_path)) { - furi_string_set_str(temp_path, app->settings.favorite_tertiary.name_or_path); - } + // Select favorite fap in file browser + if(favorite_fap_selector_file_exists(curr_favorite_app->name_or_path)) { + furi_string_set_str(temp_path, curr_favorite_app->name_or_path); } - submenu_reset(app->submenu); if(dialog_file_browser_show(app->dialogs, temp_path, temp_path, &browser_options)) { - if(primary_favorite == 0) { - app->settings.favorite_primary.is_external = true; - strncpy( - app->settings.favorite_primary.name_or_path, - furi_string_get_cstr(temp_path), - MAX_APP_LENGTH); - } else if(primary_favorite == 1) { - app->settings.favorite_secondary.is_external = true; - strncpy( - app->settings.favorite_secondary.name_or_path, - furi_string_get_cstr(temp_path), - MAX_APP_LENGTH); - } else if(primary_favorite == 2) { - app->settings.favorite_tertiary.is_external = true; - strncpy( - app->settings.favorite_tertiary.name_or_path, - furi_string_get_cstr(temp_path), - MAX_APP_LENGTH); - } + submenu_reset(app->submenu); // Prevent menu from being shown when we exiting scene + curr_favorite_app->is_external = true; + strncpy( + curr_favorite_app->name_or_path, + furi_string_get_cstr(temp_path), + MAX_APP_LENGTH); + consumed = true; } + } else { + curr_favorite_app->is_external = false; + strncpy( + curr_favorite_app->name_or_path, FLIPPER_APPS[event.event].name, MAX_APP_LENGTH); + consumed = true; } - scene_manager_previous_scene(app->scene_manager); + if(consumed) { + scene_manager_previous_scene(app->scene_manager); + }; consumed = true; } From 24ad48d3908194c92aa20dc139f76cb3feb0ac46 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 26 May 2023 13:22:06 +0300 Subject: [PATCH 69/92] Update TOTP --- .../totp/ui/fonts/712serif/712serif.c | 940 +++++++++++++ .../totp/ui/fonts/712serif/712serif.h | 8 + .../external/totp/ui/fonts/active_font.h | 27 + .../totp/ui/fonts/bedstead/bedstead.c | 1056 +++++++++++++++ .../totp/ui/fonts/bedstead/bedstead.h | 8 + .../totp/ui/fonts/graph35pix/graph35pix.c | 940 +++++++++++++ .../totp/ui/fonts/graph35pix/graph35pix.h | 8 + .../totp/ui/fonts/karma_future/karma_future.c | 1172 +++++++++++++++++ .../totp/ui/fonts/karma_future/karma_future.h | 8 + .../{mode-nine => mode_nine}/mode_nine.c | 0 .../{mode-nine => mode_nine}/mode_nine.h | 0 .../totp/ui/fonts/redhat_mono/redhat_mono.c | 1057 +++++++++++++++ .../totp/ui/fonts/redhat_mono/redhat_mono.h | 8 + .../external/totp/ui/fonts/zector/zector.c | 1056 +++++++++++++++ .../external/totp/ui/fonts/zector/zector.h | 8 + .../ui/scenes/add_new_token/totp_input_text.c | 2 +- .../add_new_token/totp_scene_add_new_token.c | 136 +- .../scenes/app_settings/totp_app_settings.c | 201 +-- .../authenticate/totp_scene_authenticate.c | 79 +- .../totp_scene_generate_token.c | 111 +- .../scenes/token_menu/totp_scene_token_menu.c | 81 +- .../generate_totp_code/generate_totp_code.c | 15 +- .../external/totp/workers/type_code_common.c | 7 +- 23 files changed, 6622 insertions(+), 306 deletions(-) create mode 100644 applications/external/totp/ui/fonts/712serif/712serif.c create mode 100644 applications/external/totp/ui/fonts/712serif/712serif.h create mode 100644 applications/external/totp/ui/fonts/active_font.h create mode 100644 applications/external/totp/ui/fonts/bedstead/bedstead.c create mode 100644 applications/external/totp/ui/fonts/bedstead/bedstead.h create mode 100644 applications/external/totp/ui/fonts/graph35pix/graph35pix.c create mode 100644 applications/external/totp/ui/fonts/graph35pix/graph35pix.h create mode 100644 applications/external/totp/ui/fonts/karma_future/karma_future.c create mode 100644 applications/external/totp/ui/fonts/karma_future/karma_future.h rename applications/external/totp/ui/fonts/{mode-nine => mode_nine}/mode_nine.c (100%) rename applications/external/totp/ui/fonts/{mode-nine => mode_nine}/mode_nine.h (100%) create mode 100644 applications/external/totp/ui/fonts/redhat_mono/redhat_mono.c create mode 100644 applications/external/totp/ui/fonts/redhat_mono/redhat_mono.h create mode 100644 applications/external/totp/ui/fonts/zector/zector.c create mode 100644 applications/external/totp/ui/fonts/zector/zector.h diff --git a/applications/external/totp/ui/fonts/712serif/712serif.c b/applications/external/totp/ui/fonts/712serif/712serif.c new file mode 100644 index 0000000000..0fe73378ce --- /dev/null +++ b/applications/external/totp/ui/fonts/712serif/712serif.c @@ -0,0 +1,940 @@ +#include "712serif.h" + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +/* +** Font data for 7:12 Serif 24pt +*/ + +/* Character bitmaps for 7:12 Serif 24pt */ +const uint8_t _712Serif_24ptBitmaps[] = { + /* @0 '-' (14 pixels wide) */ + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0xFC, + 0x0F, + 0xFC, + 0x0F, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + + /* @28 '0' (14 pixels wide) */ + 0xF0, + 0x03, + 0xF0, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x03, + 0xF0, + 0x03, + + /* @56 '1' (14 pixels wide) */ + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xFC, + 0x00, + 0xFC, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xFC, + 0x0F, + 0xFC, + 0x0F, + + /* @84 '2' (14 pixels wide) */ + 0xF0, + 0x03, + 0xF0, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0xC0, + 0x03, + 0xC0, + 0x03, + 0x30, + 0x00, + 0x30, + 0x00, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xFC, + 0x0F, + 0xFC, + 0x0F, + + /* @112 '3' (14 pixels wide) */ + 0xF0, + 0x03, + 0xF0, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0xC0, + 0x03, + 0xC0, + 0x03, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x03, + 0xF0, + 0x03, + + /* @140 '4' (14 pixels wide) */ + 0x30, + 0x03, + 0x30, + 0x03, + 0x30, + 0x03, + 0x30, + 0x03, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0xFC, + 0x0F, + 0xFC, + 0x0F, + 0x00, + 0x03, + 0x00, + 0x03, + 0xC0, + 0x0F, + 0xC0, + 0x0F, + + /* @168 '5' (14 pixels wide) */ + 0xFC, + 0x0F, + 0xFC, + 0x0F, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0xFC, + 0x03, + 0xFC, + 0x03, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x03, + 0xF0, + 0x03, + + /* @196 '6' (14 pixels wide) */ + 0xF0, + 0x03, + 0xF0, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0xFC, + 0x03, + 0xFC, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x03, + 0xF0, + 0x03, + + /* @224 '7' (14 pixels wide) */ + 0xFC, + 0x0F, + 0xFC, + 0x0F, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + + /* @252 '8' (14 pixels wide) */ + 0xF0, + 0x03, + 0xF0, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x03, + 0xF0, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x03, + 0xF0, + 0x03, + + /* @280 '9' (14 pixels wide) */ + 0xF0, + 0x03, + 0xF0, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x0F, + 0xF0, + 0x0F, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x03, + 0xF0, + 0x03, + + /* @308 'B' (14 pixels wide) */ + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0xFC, + 0x0F, + 0xFC, + 0x0F, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0xFF, + 0x0F, + 0xFF, + 0x0F, + + /* @336 'C' (14 pixels wide) */ + 0xF0, + 0x33, + 0xF0, + 0x33, + 0x0C, + 0x3C, + 0x0C, + 0x3C, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x30, + 0x03, + 0x30, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x03, + 0xF0, + 0x03, + + /* @364 'D' (14 pixels wide) */ + 0xFF, + 0x03, + 0xFF, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xFF, + 0x03, + 0xFF, + 0x03, + + /* @392 'F' (14 pixels wide) */ + 0xFF, + 0x3F, + 0xFF, + 0x3F, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0xFC, + 0x03, + 0xFC, + 0x03, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x3F, + 0x00, + 0x3F, + 0x00, + + /* @420 'G' (14 pixels wide) */ + 0xF0, + 0x33, + 0xF0, + 0x33, + 0x0C, + 0x3C, + 0x0C, + 0x3C, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x3F, + 0x03, + 0x3F, + 0x03, + 0x30, + 0x03, + 0x30, + 0x0C, + 0x3C, + 0x0C, + 0x3C, + 0xF0, + 0x33, + 0xF0, + 0x33, + + /* @448 'H' (14 pixels wide) */ + 0x3F, + 0x3F, + 0x3F, + 0x3F, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xFC, + 0x0F, + 0xFC, + 0x0F, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x3F, + 0x3F, + 0x3F, + 0x3F, + + /* @476 'J' (14 pixels wide) */ + 0x00, + 0x3F, + 0x00, + 0x3F, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x03, + 0xF0, + 0x03, + + /* @504 'K' (14 pixels wide) */ + 0x3F, + 0x3F, + 0x3F, + 0x3F, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0xFC, + 0x00, + 0xFC, + 0x00, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x3F, + 0x3F, + 0x3F, + 0x3F, + + /* @532 'M' (14 pixels wide) */ + 0x0F, + 0x3C, + 0x0F, + 0x3C, + 0x3C, + 0x0F, + 0x3C, + 0x0F, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x3F, + 0x3F, + 0x3F, + 0x3F, + + /* @560 'N' (14 pixels wide) */ + 0x0F, + 0x3F, + 0x0F, + 0x3F, + 0x3C, + 0x0C, + 0x3C, + 0x0C, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0x0C, + 0x0F, + 0x0C, + 0x0F, + 0x3F, + 0x0C, + 0x3F, + 0x0C, + + /* @588 'P' (14 pixels wide) */ + 0xFF, + 0x0F, + 0xFF, + 0x0F, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x3C, + 0x30, + 0x3C, + 0x30, + 0xCC, + 0x0F, + 0xCC, + 0x0F, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x3F, + 0x00, + 0x3F, + 0x00, + + /* @616 'Q' (14 pixels wide) */ + 0xF0, + 0x03, + 0xF0, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x03, + 0x30, + 0x03, + 0x30, + 0xF3, + 0x30, + 0xF3, + 0x30, + 0x03, + 0x33, + 0x03, + 0x33, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xF0, + 0x33, + 0xF0, + 0x33, + + /* @644 'R' (14 pixels wide) */ + 0xFF, + 0x0F, + 0xFF, + 0x0F, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0x0C, + 0x30, + 0xFC, + 0x0F, + 0xFC, + 0x0F, + 0x0C, + 0x03, + 0x0C, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x3F, + 0x3F, + 0x3F, + 0x3F, + + /* @672 'T' (14 pixels wide) */ + 0xFF, + 0x3F, + 0xFF, + 0x3F, + 0xC3, + 0x30, + 0xC3, + 0x30, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xF0, + 0x03, + 0xF0, + 0x03, + + /* @700 'V' (14 pixels wide) */ + 0x3F, + 0x3F, + 0x3F, + 0x3F, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x30, + 0x03, + 0x30, + 0x03, + 0x30, + 0x03, + 0x30, + 0x03, + 0xC0, + 0x00, + 0xC0, + 0x00, + + /* @728 'W' (14 pixels wide) */ + 0x3F, + 0x3F, + 0x3F, + 0x3F, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0xCC, + 0x0C, + 0x30, + 0x03, + 0x30, + 0x03, + 0x30, + 0x03, + 0x30, + 0x03, + + /* @756 'X' (14 pixels wide) */ + 0x3F, + 0x3F, + 0x3F, + 0x3F, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x30, + 0x03, + 0x30, + 0x03, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0x30, + 0x03, + 0x30, + 0x03, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x3F, + 0x3F, + 0x3F, + 0x3F, + + /* @784 'Y' (14 pixels wide) */ + 0x3F, + 0x3F, + 0x3F, + 0x3F, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x30, + 0x03, + 0x30, + 0x03, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xF0, + 0x03, + 0xF0, + 0x03, +}; + +/* Character descriptors for 7:12 Serif 24pt */ +/* { [Char width in bits], [Offset into _712Serif_24ptCharBitmaps in bytes] } */ +const FONT_CHAR_INFO _712Serif_24ptDescriptors[] = { + {14, 0}, /* - */ + {0, 0}, /* . */ + {0, 0}, /* / */ + {14, 28}, /* 0 */ + {14, 56}, /* 1 */ + {14, 84}, /* 2 */ + {14, 112}, /* 3 */ + {14, 140}, /* 4 */ + {14, 168}, /* 5 */ + {14, 196}, /* 6 */ + {14, 224}, /* 7 */ + {14, 252}, /* 8 */ + {14, 280}, /* 9 */ + {0, 0}, /* : */ + {0, 0}, /* ; */ + {0, 0}, /* < */ + {0, 0}, /* = */ + {0, 0}, /* > */ + {0, 0}, /* ? */ + {0, 0}, /* @ */ + {0, 0}, /* A */ + {14, 308}, /* B */ + {14, 336}, /* C */ + {14, 364}, /* D */ + {0, 0}, /* E */ + {14, 392}, /* F */ + {14, 420}, /* G */ + {14, 448}, /* H */ + {0, 0}, /* I */ + {14, 476}, /* J */ + {14, 504}, /* K */ + {0, 0}, /* L */ + {14, 532}, /* M */ + {14, 560}, /* N */ + {0, 0}, /* O */ + {14, 588}, /* P */ + {14, 616}, /* Q */ + {14, 644}, /* R */ + {0, 0}, /* S */ + {14, 672}, /* T */ + {0, 0}, /* U */ + {14, 700}, /* V */ + {14, 728}, /* W */ + {14, 756}, /* X */ + {14, 784}, /* Y */ +}; + +/* Font information for 7:12 Serif 24pt */ +const FONT_INFO _712Serif_24ptFontInfo = { + 14, /* Character height */ + '-', /* Start character */ + 'Y', /* End character */ + 2, /* Width, in pixels, of space character */ + _712Serif_24ptDescriptors, /* Character descriptor array */ + _712Serif_24ptBitmaps, /* Character bitmap array */ +}; diff --git a/applications/external/totp/ui/fonts/712serif/712serif.h b/applications/external/totp/ui/fonts/712serif/712serif.h new file mode 100644 index 0000000000..81959064d6 --- /dev/null +++ b/applications/external/totp/ui/fonts/712serif/712serif.h @@ -0,0 +1,8 @@ +#pragma once + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +#include "../font_info.h" + +/* Font data for 7:12 Serif 24pt */ +extern const FONT_INFO _712Serif_24ptFontInfo; diff --git a/applications/external/totp/ui/fonts/active_font.h b/applications/external/totp/ui/fonts/active_font.h new file mode 100644 index 0000000000..58c1e2d176 --- /dev/null +++ b/applications/external/totp/ui/fonts/active_font.h @@ -0,0 +1,27 @@ +#pragma once + +#include "../../features_config.h" +#include "font_info.h" + +#if TOTP_FONT == TOTP_FONT_MODENINE +#include "mode_nine/mode_nine.h" +#define TOTP_CODE_FONT_INFO modeNine_15ptFontInfo +#elif TOTP_FONT == TOTP_FONT_REDHATMONO +#include "redhat_mono/redhat_mono.h" +#define TOTP_CODE_FONT_INFO redHatMono_16ptFontInfo +#elif TOTP_FONT == TOTP_FONT_BEDSTEAD +#include "bedstead/bedstead.h" +#define TOTP_CODE_FONT_INFO bedstead_17ptFontInfo +#elif TOTP_FONT == TOTP_FONT_ZECTOR +#include "zector/zector.h" +#define TOTP_CODE_FONT_INFO zector_18ptFontInfo +#elif TOTP_FONT == TOTP_FONT_712SERIF +#include "712serif/712serif.h" +#define TOTP_CODE_FONT_INFO _712Serif_24ptFontInfo +#elif TOTP_FONT == TOTP_FONT_GRAPH35PIX +#include "graph35pix/graph35pix.h" +#define TOTP_CODE_FONT_INFO graph35pix_12ptFontInfo +#elif TOTP_FONT == TOTP_FONT_KARMAFUTURE +#include "karma_future/karma_future.h" +#define TOTP_CODE_FONT_INFO karmaFuture_14ptFontInfo +#endif \ No newline at end of file diff --git a/applications/external/totp/ui/fonts/bedstead/bedstead.c b/applications/external/totp/ui/fonts/bedstead/bedstead.c new file mode 100644 index 0000000000..ec6680fabb --- /dev/null +++ b/applications/external/totp/ui/fonts/bedstead/bedstead.c @@ -0,0 +1,1056 @@ +#include "bedstead.h" + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +/* +** Font data for Bedstead 17pt +*/ + +/* Character bitmaps for Bedstead 17pt */ +const uint8_t bedstead_17ptBitmaps[] = { + /* @0 '-' (13 pixels wide) */ + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0xF8, + 0x07, + 0xF8, + 0x07, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + + /* @32 '0' (13 pixels wide) */ + 0xE0, + 0x00, + 0xF0, + 0x01, + 0xF8, + 0x03, + 0xBC, + 0x07, + 0x1E, + 0x0F, + 0x0F, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x0F, + 0x1E, + 0x1E, + 0x0F, + 0xBC, + 0x07, + 0xF8, + 0x03, + 0xF0, + 0x01, + 0xE0, + 0x00, + + /* @64 '1' (13 pixels wide) */ + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xF8, + 0x00, + 0xF8, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xF8, + 0x03, + 0xF8, + 0x03, + + /* @96 '2' (13 pixels wide) */ + 0xF0, + 0x07, + 0xFC, + 0x0F, + 0x1E, + 0x1E, + 0x1E, + 0x1C, + 0x0E, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1E, + 0xC0, + 0x0F, + 0xE0, + 0x07, + 0xF0, + 0x00, + 0x7C, + 0x00, + 0x3E, + 0x00, + 0x1E, + 0x00, + 0x0E, + 0x00, + 0xFE, + 0x1F, + 0xFE, + 0x1F, + + /* @128 '3' (13 pixels wide) */ + 0xFE, + 0x1F, + 0xFE, + 0x1F, + 0x00, + 0x1C, + 0x00, + 0x1E, + 0x00, + 0x0F, + 0x00, + 0x0F, + 0x00, + 0x07, + 0xE0, + 0x07, + 0xE0, + 0x0F, + 0x00, + 0x1E, + 0x00, + 0x1C, + 0x0E, + 0x1C, + 0x1E, + 0x1C, + 0x3E, + 0x0E, + 0xFC, + 0x0F, + 0xF8, + 0x07, + + /* @160 '4' (13 pixels wide) */ + 0x80, + 0x03, + 0x80, + 0x03, + 0xE0, + 0x03, + 0xF0, + 0x03, + 0xF8, + 0x03, + 0xBC, + 0x03, + 0x9E, + 0x03, + 0x8F, + 0x03, + 0x87, + 0x03, + 0xFF, + 0x0F, + 0xFF, + 0x0F, + 0x80, + 0x03, + 0x80, + 0x03, + 0x80, + 0x03, + 0x80, + 0x03, + 0x80, + 0x03, + + /* @192 '5' (13 pixels wide) */ + 0xFF, + 0x1F, + 0xFF, + 0x1F, + 0x07, + 0x00, + 0x07, + 0x00, + 0xFF, + 0x07, + 0xFF, + 0x0F, + 0x00, + 0x1E, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x07, + 0x1C, + 0x0F, + 0x1E, + 0xFE, + 0x0F, + 0xFC, + 0x07, + 0xFC, + 0x07, + + /* @224 '6' (13 pixels wide) */ + 0xE0, + 0x07, + 0xF0, + 0x07, + 0x78, + 0x00, + 0x3C, + 0x00, + 0x1E, + 0x00, + 0x0F, + 0x00, + 0x07, + 0x00, + 0xFF, + 0x07, + 0xFF, + 0x0F, + 0x07, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x0F, + 0x1E, + 0x1E, + 0x0F, + 0xFE, + 0x0F, + 0xFC, + 0x07, + + /* @256 '7' (13 pixels wide) */ + 0xFE, + 0x1F, + 0xFE, + 0x1F, + 0x00, + 0x1C, + 0x00, + 0x1E, + 0x00, + 0x0F, + 0x80, + 0x07, + 0xC0, + 0x03, + 0xE0, + 0x01, + 0xF0, + 0x00, + 0x78, + 0x00, + 0x38, + 0x00, + 0x38, + 0x00, + 0x38, + 0x00, + 0x38, + 0x00, + 0x38, + 0x00, + 0x38, + 0x00, + + /* @288 '8' (13 pixels wide) */ + 0xFC, + 0x07, + 0xFE, + 0x0F, + 0x0F, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x0F, + 0x1E, + 0xFE, + 0x0F, + 0xFE, + 0x0F, + 0x0F, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x0F, + 0x1E, + 0x1E, + 0x0F, + 0xFE, + 0x0F, + 0xFC, + 0x07, + + /* @320 '9' (13 pixels wide) */ + 0xFC, + 0x07, + 0xFE, + 0x0F, + 0x0F, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x0F, + 0x1C, + 0xFE, + 0x1F, + 0xFC, + 0x1F, + 0x00, + 0x1C, + 0x00, + 0x1E, + 0x00, + 0x0F, + 0x80, + 0x07, + 0xC0, + 0x03, + 0xFC, + 0x01, + 0xFC, + 0x00, + + /* @352 'B' (13 pixels wide) */ + 0xFF, + 0x07, + 0xFF, + 0x0F, + 0x07, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1E, + 0xFF, + 0x0F, + 0xFF, + 0x0F, + 0x07, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1E, + 0x07, + 0x0F, + 0xFF, + 0x0F, + 0xFF, + 0x07, + + /* @384 'C' (13 pixels wide) */ + 0xFC, + 0x01, + 0xFE, + 0x07, + 0x0F, + 0x0F, + 0x07, + 0x0F, + 0x07, + 0x0E, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x0F, + 0x8F, + 0x0F, + 0xFE, + 0x07, + 0xFC, + 0x03, + + /* @416 'D' (13 pixels wide) */ + 0xFF, + 0x07, + 0xFF, + 0x0F, + 0x07, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1E, + 0x07, + 0x0F, + 0xFF, + 0x0F, + 0xFF, + 0x07, + + /* @448 'F' (13 pixels wide) */ + 0xFF, + 0x0F, + 0xFF, + 0x0F, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0xFF, + 0x03, + 0xFF, + 0x03, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + + /* @480 'G' (13 pixels wide) */ + 0xFC, + 0x07, + 0xFE, + 0x0F, + 0x0F, + 0x1F, + 0x0F, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x87, + 0x1F, + 0x87, + 0x1F, + 0x07, + 0x1C, + 0x0F, + 0x1C, + 0xFE, + 0x1F, + 0xFC, + 0x1F, + 0xFC, + 0x1F, + + /* @512 'H' (13 pixels wide) */ + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0xFF, + 0x1F, + 0xFF, + 0x1F, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + + /* @544 'J' (13 pixels wide) */ + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x00, + 0x1C, + 0x0E, + 0x1C, + 0x1E, + 0x1C, + 0x3E, + 0x1E, + 0xFC, + 0x0F, + 0xF8, + 0x07, + + /* @576 'K' (13 pixels wide) */ + 0x07, + 0x0E, + 0x07, + 0x0F, + 0x87, + 0x07, + 0xC7, + 0x03, + 0xE7, + 0x01, + 0xF7, + 0x00, + 0x7F, + 0x00, + 0x3F, + 0x00, + 0x3F, + 0x00, + 0x7F, + 0x00, + 0xF7, + 0x00, + 0xE7, + 0x01, + 0xC7, + 0x03, + 0x87, + 0x07, + 0x07, + 0x0F, + 0x07, + 0x0E, + + /* @608 'M' (13 pixels wide) */ + 0x07, + 0x1C, + 0x07, + 0x1C, + 0xBF, + 0x1F, + 0xFF, + 0x1F, + 0xFF, + 0x1F, + 0xE7, + 0x1C, + 0xE7, + 0x1C, + 0xE7, + 0x1C, + 0xE7, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + + /* @640 'N' (13 pixels wide) */ + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x3F, + 0x1C, + 0x7F, + 0x1C, + 0xFF, + 0x1C, + 0xE7, + 0x1F, + 0xC7, + 0x1F, + 0x87, + 0x1F, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + + /* @672 'P' (13 pixels wide) */ + 0xFF, + 0x07, + 0xFF, + 0x0F, + 0x07, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1E, + 0xFF, + 0x0F, + 0xFF, + 0x07, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + 0x07, + 0x00, + + /* @704 'Q' (13 pixels wide) */ + 0xFC, + 0x07, + 0xFE, + 0x0F, + 0x0F, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0xE7, + 0x1C, + 0xE7, + 0x1F, + 0xC7, + 0x0F, + 0x8F, + 0x07, + 0xDE, + 0x0F, + 0xFE, + 0x1F, + 0xFC, + 0x1C, + + /* @736 'R' (13 pixels wide) */ + 0xFF, + 0x07, + 0xFF, + 0x0F, + 0x07, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1E, + 0xFF, + 0x0F, + 0xFF, + 0x07, + 0xE7, + 0x00, + 0xE7, + 0x01, + 0xC7, + 0x03, + 0x87, + 0x07, + 0x07, + 0x0F, + 0x07, + 0x1E, + 0x07, + 0x1C, + + /* @768 'T' (13 pixels wide) */ + 0xFF, + 0x1F, + 0xFF, + 0x1F, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + + /* @800 'V' (13 pixels wide) */ + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x1F, + 0x1F, + 0xBC, + 0x07, + 0xB8, + 0x03, + 0xB8, + 0x03, + 0xF8, + 0x07, + 0xF0, + 0x03, + 0xE0, + 0x01, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + + /* @832 'W' (13 pixels wide) */ + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0xE7, + 0x1C, + 0xE7, + 0x1C, + 0xE7, + 0x1C, + 0xE7, + 0x1C, + 0xE7, + 0x1C, + 0xFF, + 0x1F, + 0xFE, + 0x0F, + 0xFE, + 0x0F, + 0xBC, + 0x07, + + /* @864 'X' (13 pixels wide) */ + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x0F, + 0x1E, + 0x1E, + 0x0F, + 0xBC, + 0x07, + 0xF8, + 0x03, + 0xF0, + 0x01, + 0xF0, + 0x01, + 0xF8, + 0x03, + 0xBC, + 0x07, + 0x1E, + 0x0F, + 0x0F, + 0x1E, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + + /* @896 'Y' (13 pixels wide) */ + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x0F, + 0x1E, + 0x1E, + 0x0F, + 0xBC, + 0x07, + 0xF8, + 0x03, + 0xF0, + 0x01, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, +}; + +/* Character descriptors for Bedstead 17pt */ +/* { [Char width in bits], [Offset into bedstead_17ptCharBitmaps in bytes] } */ +const FONT_CHAR_INFO bedstead_17ptDescriptors[] = { + {13, 0}, /* - */ + {0, 0}, /* . */ + {0, 0}, /* / */ + {13, 32}, /* 0 */ + {13, 64}, /* 1 */ + {13, 96}, /* 2 */ + {13, 128}, /* 3 */ + {13, 160}, /* 4 */ + {13, 192}, /* 5 */ + {13, 224}, /* 6 */ + {13, 256}, /* 7 */ + {13, 288}, /* 8 */ + {13, 320}, /* 9 */ + {0, 0}, /* : */ + {0, 0}, /* ; */ + {0, 0}, /* < */ + {0, 0}, /* = */ + {0, 0}, /* > */ + {0, 0}, /* ? */ + {0, 0}, /* @ */ + {0, 0}, /* A */ + {13, 352}, /* B */ + {13, 384}, /* C */ + {13, 416}, /* D */ + {0, 0}, /* E */ + {13, 448}, /* F */ + {13, 480}, /* G */ + {13, 512}, /* H */ + {0, 0}, /* I */ + {13, 544}, /* J */ + {13, 576}, /* K */ + {0, 0}, /* L */ + {13, 608}, /* M */ + {13, 640}, /* N */ + {0, 0}, /* O */ + {13, 672}, /* P */ + {13, 704}, /* Q */ + {13, 736}, /* R */ + {0, 0}, /* S */ + {13, 768}, /* T */ + {0, 0}, /* U */ + {13, 800}, /* V */ + {13, 832}, /* W */ + {13, 864}, /* X */ + {13, 896}, /* Y */ +}; + +/* Font information for Bedstead 17pt */ +const FONT_INFO bedstead_17ptFontInfo = { + 16, /* Character height */ + '-', /* Start character */ + 'Y', /* End character */ + 2, /* Width, in pixels, of space character */ + bedstead_17ptDescriptors, /* Character descriptor array */ + bedstead_17ptBitmaps, /* Character bitmap array */ +}; diff --git a/applications/external/totp/ui/fonts/bedstead/bedstead.h b/applications/external/totp/ui/fonts/bedstead/bedstead.h new file mode 100644 index 0000000000..0f4c109495 --- /dev/null +++ b/applications/external/totp/ui/fonts/bedstead/bedstead.h @@ -0,0 +1,8 @@ +#pragma once + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +#include "../font_info.h" + +/* Font data for Bedstead 17pt */ +extern const FONT_INFO bedstead_17ptFontInfo; diff --git a/applications/external/totp/ui/fonts/graph35pix/graph35pix.c b/applications/external/totp/ui/fonts/graph35pix/graph35pix.c new file mode 100644 index 0000000000..fd93d4de9b --- /dev/null +++ b/applications/external/totp/ui/fonts/graph35pix/graph35pix.c @@ -0,0 +1,940 @@ +#include "graph35pix.h" + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +/* +** Font data for Graph 35+ pix 12pt +*/ + +/* Character bitmaps for Graph 35+ pix 12pt */ +const uint8_t graph35pix_12ptBitmaps[] = { + /* @0 '-' (10 pixels wide) */ + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0xFF, + 0x03, + 0xFF, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + + /* @28 '0' (10 pixels wide) */ + 0xFC, + 0x00, + 0xFC, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0xC3, + 0x03, + 0xC3, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0x0F, + 0x03, + 0x0F, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFC, + 0x00, + 0xFC, + 0x00, + + /* @56 '1' (10 pixels wide) */ + 0x30, + 0x00, + 0x30, + 0x00, + 0x3C, + 0x00, + 0x3C, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0xFC, + 0x00, + 0xFC, + 0x00, + + /* @84 '2' (10 pixels wide) */ + 0xFC, + 0x00, + 0xFC, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0xFF, + 0x03, + 0xFF, + 0x03, + + /* @112 '3' (10 pixels wide) */ + 0xFF, + 0x03, + 0xFF, + 0x03, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0x00, + 0x03, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFC, + 0x00, + 0xFC, + 0x00, + + /* @140 '4' (10 pixels wide) */ + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xF0, + 0x00, + 0xF0, + 0x00, + 0xCC, + 0x00, + 0xCC, + 0x00, + 0xC3, + 0x00, + 0xC3, + 0x00, + 0xFF, + 0x03, + 0xFF, + 0x03, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + + /* @168 '5' (10 pixels wide) */ + 0xFF, + 0x03, + 0xFF, + 0x03, + 0x03, + 0x00, + 0x03, + 0x00, + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFC, + 0x00, + 0xFC, + 0x00, + + /* @196 '6' (10 pixels wide) */ + 0xF0, + 0x00, + 0xF0, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFC, + 0x00, + 0xFC, + 0x00, + + /* @224 '7' (10 pixels wide) */ + 0xFF, + 0x03, + 0xFF, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + + /* @252 '8' (10 pixels wide) */ + 0xFC, + 0x00, + 0xFC, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFC, + 0x00, + 0xFC, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFC, + 0x00, + 0xFC, + 0x00, + + /* @280 '9' (10 pixels wide) */ + 0xFC, + 0x00, + 0xFC, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFC, + 0x03, + 0xFC, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0x3C, + 0x00, + 0x3C, + 0x00, + + /* @308 'B' (10 pixels wide) */ + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFF, + 0x00, + 0xFF, + 0x00, + + /* @336 'C' (10 pixels wide) */ + 0xFC, + 0x00, + 0xFC, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFC, + 0x00, + 0xFC, + 0x00, + + /* @364 'D' (10 pixels wide) */ + 0x3F, + 0x00, + 0x3F, + 0x00, + 0xC3, + 0x00, + 0xC3, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xC3, + 0x00, + 0xC3, + 0x00, + 0x3F, + 0x00, + 0x3F, + 0x00, + + /* @392 'F' (10 pixels wide) */ + 0xFF, + 0x03, + 0xFF, + 0x03, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + + /* @420 'G' (10 pixels wide) */ + 0xFC, + 0x00, + 0xFC, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x00, + 0x03, + 0x00, + 0xF3, + 0x03, + 0xF3, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFC, + 0x03, + 0xFC, + 0x03, + + /* @448 'H' (10 pixels wide) */ + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFF, + 0x03, + 0xFF, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + + /* @476 'J' (10 pixels wide) */ + 0xF0, + 0x03, + 0xF0, + 0x03, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC0, + 0x00, + 0xC3, + 0x00, + 0xC3, + 0x00, + 0x3C, + 0x00, + 0x3C, + 0x00, + + /* @504 'K' (10 pixels wide) */ + 0x03, + 0x03, + 0x03, + 0x03, + 0xC3, + 0x00, + 0xC3, + 0x00, + 0x33, + 0x00, + 0x33, + 0x00, + 0x0F, + 0x00, + 0x0F, + 0x00, + 0x33, + 0x00, + 0x33, + 0x00, + 0xC3, + 0x00, + 0xC3, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + + /* @532 'M' (10 pixels wide) */ + 0x03, + 0x03, + 0x03, + 0x03, + 0xCF, + 0x03, + 0xCF, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + + /* @560 'N' (10 pixels wide) */ + 0x03, + 0x03, + 0x03, + 0x03, + 0x0F, + 0x03, + 0x0F, + 0x03, + 0x0F, + 0x03, + 0x0F, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0xC3, + 0x03, + 0xC3, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + + /* @588 'P' (10 pixels wide) */ + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + + /* @616 'Q' (10 pixels wide) */ + 0xFC, + 0x00, + 0xFC, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0xC3, + 0x00, + 0xC3, + 0x00, + 0x3C, + 0x03, + 0x3C, + 0x03, + + /* @644 'R' (10 pixels wide) */ + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x33, + 0x00, + 0x33, + 0x00, + 0xC3, + 0x00, + 0xC3, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + + /* @672 'T' (10 pixels wide) */ + 0xFF, + 0x03, + 0xFF, + 0x03, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + + /* @700 'V' (10 pixels wide) */ + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xCC, + 0x00, + 0xCC, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + + /* @728 'W' (10 pixels wide) */ + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0x33, + 0x03, + 0xCC, + 0x00, + 0xCC, + 0x00, + + /* @756 'X' (10 pixels wide) */ + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xCC, + 0x00, + 0xCC, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0xCC, + 0x00, + 0xCC, + 0x00, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + + /* @784 'Y' (10 pixels wide) */ + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0xCC, + 0x00, + 0xCC, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, + 0x30, + 0x00, +}; + +/* Character descriptors for Graph 35+ pix 12pt */ +/* { [Char width in bits], [Offset into graph35pix_12ptCharBitmaps in bytes] } */ +const FONT_CHAR_INFO graph35pix_12ptDescriptors[] = { + {10, 0}, /* - */ + {0, 0}, /* . */ + {0, 0}, /* / */ + {10, 28}, /* 0 */ + {10, 56}, /* 1 */ + {10, 84}, /* 2 */ + {10, 112}, /* 3 */ + {10, 140}, /* 4 */ + {10, 168}, /* 5 */ + {10, 196}, /* 6 */ + {10, 224}, /* 7 */ + {10, 252}, /* 8 */ + {10, 280}, /* 9 */ + {0, 0}, /* : */ + {0, 0}, /* ; */ + {0, 0}, /* < */ + {0, 0}, /* = */ + {0, 0}, /* > */ + {0, 0}, /* ? */ + {0, 0}, /* @ */ + {0, 0}, /* A */ + {10, 308}, /* B */ + {10, 336}, /* C */ + {10, 364}, /* D */ + {0, 0}, /* E */ + {10, 392}, /* F */ + {10, 420}, /* G */ + {10, 448}, /* H */ + {0, 0}, /* I */ + {10, 476}, /* J */ + {10, 504}, /* K */ + {0, 0}, /* L */ + {10, 532}, /* M */ + {10, 560}, /* N */ + {0, 0}, /* O */ + {10, 588}, /* P */ + {10, 616}, /* Q */ + {10, 644}, /* R */ + {0, 0}, /* S */ + {10, 672}, /* T */ + {0, 0}, /* U */ + {10, 700}, /* V */ + {10, 728}, /* W */ + {10, 756}, /* X */ + {10, 784}, /* Y */ +}; + +/* Font information for Graph 35+ pix 12pt */ +const FONT_INFO graph35pix_12ptFontInfo = { + 14, /* Character height */ + '-', /* Start character */ + 'Y', /* End character */ + 2, /* Width, in pixels, of space character */ + graph35pix_12ptDescriptors, /* Character descriptor array */ + graph35pix_12ptBitmaps, /* Character bitmap array */ +}; diff --git a/applications/external/totp/ui/fonts/graph35pix/graph35pix.h b/applications/external/totp/ui/fonts/graph35pix/graph35pix.h new file mode 100644 index 0000000000..07838e3ba7 --- /dev/null +++ b/applications/external/totp/ui/fonts/graph35pix/graph35pix.h @@ -0,0 +1,8 @@ +#pragma once + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +#include "../font_info.h" + +/* Font data for Graph 35+ pix 12pt */ +extern const FONT_INFO graph35pix_12ptFontInfo; diff --git a/applications/external/totp/ui/fonts/karma_future/karma_future.c b/applications/external/totp/ui/fonts/karma_future/karma_future.c new file mode 100644 index 0000000000..ed62014414 --- /dev/null +++ b/applications/external/totp/ui/fonts/karma_future/karma_future.c @@ -0,0 +1,1172 @@ +#include "karma_future.h" + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +/* +** Font data for Karma Future 14pt +*/ + +/* Character bitmaps for Karma Future 14pt */ +const uint8_t karmaFuture_14ptBitmaps[] = { + /* @0 '-' (12 pixels wide) */ + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0xFE, + 0x03, + 0x02, + 0x02, + 0x02, + 0x02, + 0xFE, + 0x03, + 0xFC, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + + /* @36 '0' (12 pixels wide) */ + 0xF8, + 0x01, + 0x0E, + 0x03, + 0x02, + 0x06, + 0xF3, + 0x06, + 0xF9, + 0x0C, + 0x79, + 0x0C, + 0x39, + 0x0D, + 0x99, + 0x0C, + 0xC9, + 0x0C, + 0xE9, + 0x0C, + 0xF1, + 0x0C, + 0xF1, + 0x0C, + 0xF1, + 0x0C, + 0xF3, + 0x0E, + 0x02, + 0x0E, + 0x0E, + 0x07, + 0xFC, + 0x07, + 0xF8, + 0x01, + + /* @72 '1' (12 pixels wide) */ + 0x70, + 0x00, + 0xD8, + 0x00, + 0xCE, + 0x00, + 0xC2, + 0x00, + 0xC2, + 0x00, + 0xDE, + 0x00, + 0xDC, + 0x00, + 0xDC, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xDE, + 0x03, + 0x02, + 0x02, + 0x02, + 0x02, + 0xFE, + 0x03, + 0xFC, + 0x03, + + /* @108 '2' (12 pixels wide) */ + 0xFC, + 0x03, + 0x06, + 0x03, + 0x03, + 0x06, + 0xF1, + 0x04, + 0xF9, + 0x0C, + 0xF9, + 0x0C, + 0x7F, + 0x0E, + 0x3E, + 0x0F, + 0x1E, + 0x0F, + 0x90, + 0x07, + 0xC8, + 0x03, + 0xE4, + 0x01, + 0xE6, + 0x00, + 0xF3, + 0x07, + 0x01, + 0x0C, + 0x01, + 0x0C, + 0xFF, + 0x0F, + 0xFE, + 0x0F, + + /* @144 '3' (12 pixels wide) */ + 0xFC, + 0x03, + 0x06, + 0x03, + 0x03, + 0x06, + 0xF1, + 0x04, + 0xF9, + 0x0C, + 0xFF, + 0x0C, + 0xFE, + 0x0C, + 0x0E, + 0x0E, + 0x08, + 0x0F, + 0xF8, + 0x0E, + 0xF8, + 0x04, + 0xFF, + 0x0C, + 0xF9, + 0x0C, + 0xF1, + 0x0C, + 0x03, + 0x0E, + 0x06, + 0x0F, + 0xFC, + 0x07, + 0xFC, + 0x03, + + /* @180 '4' (12 pixels wide) */ + 0xE0, + 0x03, + 0x30, + 0x03, + 0x10, + 0x03, + 0x08, + 0x03, + 0x4C, + 0x03, + 0x64, + 0x03, + 0x72, + 0x03, + 0x73, + 0x03, + 0x79, + 0x03, + 0x01, + 0x04, + 0x01, + 0x0C, + 0x7F, + 0x0F, + 0x7E, + 0x0F, + 0x7E, + 0x0F, + 0x40, + 0x03, + 0x40, + 0x03, + 0xC0, + 0x03, + 0x80, + 0x03, + + /* @216 '5' (12 pixels wide) */ + 0xFF, + 0x07, + 0x01, + 0x0C, + 0x01, + 0x0C, + 0xF9, + 0x0F, + 0xF9, + 0x0F, + 0xF9, + 0x0F, + 0x01, + 0x03, + 0x03, + 0x06, + 0xFE, + 0x04, + 0xFE, + 0x0C, + 0xFC, + 0x0C, + 0xFF, + 0x0C, + 0xF9, + 0x0C, + 0xF1, + 0x0C, + 0x03, + 0x0E, + 0x06, + 0x0F, + 0xFC, + 0x07, + 0xF8, + 0x03, + + /* @252 '6' (12 pixels wide) */ + 0xF0, + 0x03, + 0x10, + 0x03, + 0x08, + 0x03, + 0xCC, + 0x03, + 0xE6, + 0x03, + 0xF2, + 0x03, + 0xF2, + 0x00, + 0x01, + 0x03, + 0x01, + 0x06, + 0xF1, + 0x04, + 0xF9, + 0x0C, + 0xF9, + 0x0C, + 0xF9, + 0x0C, + 0xF1, + 0x0C, + 0x03, + 0x0E, + 0x06, + 0x0F, + 0xFC, + 0x07, + 0xF8, + 0x03, + + /* @288 '7' (12 pixels wide) */ + 0xFF, + 0x07, + 0x01, + 0x0C, + 0x01, + 0x0C, + 0xFF, + 0x0E, + 0xFE, + 0x0E, + 0x7E, + 0x0F, + 0x40, + 0x07, + 0x60, + 0x07, + 0x20, + 0x03, + 0x30, + 0x03, + 0x90, + 0x01, + 0x90, + 0x01, + 0xD0, + 0x00, + 0xC8, + 0x00, + 0xE8, + 0x00, + 0xE8, + 0x00, + 0x78, + 0x00, + 0x78, + 0x00, + + /* @324 '8' (12 pixels wide) */ + 0xF8, + 0x01, + 0x0C, + 0x01, + 0x06, + 0x03, + 0x72, + 0x06, + 0xF2, + 0x06, + 0xF2, + 0x06, + 0x72, + 0x06, + 0x06, + 0x07, + 0x02, + 0x06, + 0xF1, + 0x04, + 0xF9, + 0x0C, + 0xF9, + 0x0C, + 0xF9, + 0x0C, + 0xF1, + 0x0C, + 0x03, + 0x0E, + 0x06, + 0x0F, + 0xFC, + 0x07, + 0xF8, + 0x03, + + /* @360 '9' (12 pixels wide) */ + 0xFC, + 0x03, + 0x06, + 0x03, + 0x03, + 0x06, + 0xF1, + 0x04, + 0xF9, + 0x0C, + 0xF9, + 0x0C, + 0xF1, + 0x0C, + 0x03, + 0x0C, + 0x06, + 0x0C, + 0xFE, + 0x0E, + 0x7C, + 0x0E, + 0x38, + 0x0F, + 0x30, + 0x07, + 0x1C, + 0x07, + 0x84, + 0x03, + 0xC4, + 0x01, + 0xFC, + 0x00, + 0xF8, + 0x00, + + /* @396 'B' (12 pixels wide) */ + 0xFE, + 0x01, + 0x02, + 0x03, + 0x02, + 0x02, + 0x72, + 0x06, + 0xF2, + 0x06, + 0xF2, + 0x06, + 0x72, + 0x06, + 0x02, + 0x06, + 0x02, + 0x06, + 0xF2, + 0x0C, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0C, + 0x02, + 0x0E, + 0x02, + 0x0E, + 0xFE, + 0x07, + 0xFC, + 0x03, + + /* @432 'C' (12 pixels wide) */ + 0xF0, + 0x03, + 0x18, + 0x02, + 0x0C, + 0x06, + 0xE4, + 0x0C, + 0xE6, + 0x0D, + 0xF2, + 0x0F, + 0x72, + 0x0F, + 0x32, + 0x0F, + 0x12, + 0x00, + 0x12, + 0x00, + 0x12, + 0x00, + 0x32, + 0x07, + 0xA6, + 0x0D, + 0xE4, + 0x0C, + 0x08, + 0x0E, + 0x18, + 0x0E, + 0xF0, + 0x07, + 0xF0, + 0x03, + + /* @468 'D' (12 pixels wide) */ + 0xFE, + 0x01, + 0x02, + 0x03, + 0x02, + 0x02, + 0x72, + 0x06, + 0xF2, + 0x06, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0E, + 0xF2, + 0x0E, + 0x72, + 0x0E, + 0x02, + 0x06, + 0x02, + 0x07, + 0xFE, + 0x03, + 0xFC, + 0x01, + + /* @504 'F' (12 pixels wide) */ + 0xFE, + 0x07, + 0x02, + 0x0C, + 0x02, + 0x0C, + 0xF2, + 0x0F, + 0xF2, + 0x0F, + 0xF2, + 0x0F, + 0x12, + 0x00, + 0xF2, + 0x03, + 0x02, + 0x02, + 0xF2, + 0x03, + 0xF2, + 0x03, + 0xF2, + 0x03, + 0x12, + 0x00, + 0x12, + 0x00, + 0x12, + 0x00, + 0x12, + 0x00, + 0x1E, + 0x00, + 0x1C, + 0x00, + + /* @540 'G' (12 pixels wide) */ + 0xF0, + 0x07, + 0x18, + 0x06, + 0x0C, + 0x0C, + 0xE4, + 0x0D, + 0xE6, + 0x0F, + 0xF2, + 0x0F, + 0xF2, + 0x0F, + 0x32, + 0x04, + 0x32, + 0x0C, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xE6, + 0x0D, + 0xE6, + 0x0D, + 0xE4, + 0x0D, + 0x08, + 0x0C, + 0x18, + 0x0C, + 0xF0, + 0x0F, + 0xF0, + 0x0F, + + /* @576 'H' (12 pixels wide) */ + 0x1E, + 0x07, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0xF2, + 0x0D, + 0x02, + 0x0C, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x1E, + 0x0F, + 0x1C, + 0x0F, + + /* @612 'J' (12 pixels wide) */ + 0x80, + 0x03, + 0x80, + 0x06, + 0x80, + 0x06, + 0x80, + 0x06, + 0x80, + 0x06, + 0x80, + 0x06, + 0x80, + 0x06, + 0x80, + 0x06, + 0x80, + 0x06, + 0x80, + 0x06, + 0x8E, + 0x06, + 0x8A, + 0x06, + 0xDA, + 0x06, + 0x72, + 0x06, + 0x02, + 0x06, + 0x06, + 0x03, + 0xFC, + 0x03, + 0xF8, + 0x01, + + /* @648 'K' (12 pixels wide) */ + 0x1E, + 0x07, + 0x92, + 0x0D, + 0xD2, + 0x0C, + 0x72, + 0x0E, + 0x32, + 0x0E, + 0x12, + 0x0F, + 0x92, + 0x07, + 0xC2, + 0x03, + 0xC2, + 0x01, + 0x92, + 0x01, + 0x12, + 0x01, + 0x32, + 0x02, + 0x32, + 0x02, + 0x72, + 0x06, + 0xD2, + 0x0C, + 0x92, + 0x0D, + 0x9E, + 0x0F, + 0x1C, + 0x0F, + + /* @684 'M' (12 pixels wide) */ + 0x1E, + 0x07, + 0x92, + 0x0D, + 0xA2, + 0x0C, + 0xE2, + 0x0C, + 0x62, + 0x0C, + 0x62, + 0x0C, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x92, + 0x0D, + 0x92, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x1E, + 0x0F, + 0x1C, + 0x0F, + + /* @720 'N' (12 pixels wide) */ + 0x1E, + 0x07, + 0x12, + 0x0D, + 0x22, + 0x0D, + 0x62, + 0x0D, + 0x62, + 0x0D, + 0xD2, + 0x0D, + 0xD2, + 0x0D, + 0x92, + 0x0D, + 0x92, + 0x0D, + 0x32, + 0x0D, + 0x32, + 0x0D, + 0x72, + 0x0C, + 0x52, + 0x0C, + 0xD2, + 0x0C, + 0x92, + 0x0C, + 0x92, + 0x0D, + 0x1E, + 0x0F, + 0x1C, + 0x0F, + + /* @756 'P' (12 pixels wide) */ + 0xFE, + 0x03, + 0x02, + 0x02, + 0x02, + 0x06, + 0xF2, + 0x0C, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0C, + 0x02, + 0x0E, + 0x02, + 0x0E, + 0xF2, + 0x0F, + 0xF2, + 0x07, + 0xF2, + 0x03, + 0x12, + 0x00, + 0x12, + 0x00, + 0x12, + 0x00, + 0x1E, + 0x00, + 0x1C, + 0x00, + + /* @792 'Q' (12 pixels wide) */ + 0xF0, + 0x01, + 0x18, + 0x03, + 0x0C, + 0x02, + 0x64, + 0x06, + 0xE6, + 0x06, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0x32, + 0x0D, + 0x26, + 0x0E, + 0x26, + 0x0E, + 0x64, + 0x0E, + 0x08, + 0x0C, + 0x18, + 0x0D, + 0xF0, + 0x0F, + 0xF0, + 0x0F, + + /* @828 'R' (12 pixels wide) */ + 0xFE, + 0x03, + 0x02, + 0x02, + 0x02, + 0x06, + 0xF2, + 0x0C, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0D, + 0xF2, + 0x0C, + 0x02, + 0x0E, + 0x02, + 0x0E, + 0x12, + 0x0F, + 0x32, + 0x06, + 0x32, + 0x06, + 0x72, + 0x06, + 0xD2, + 0x0C, + 0x92, + 0x0D, + 0x9E, + 0x0F, + 0x1C, + 0x0F, + + /* @864 'T' (12 pixels wide) */ + 0xFE, + 0x03, + 0x02, + 0x02, + 0x02, + 0x02, + 0xDE, + 0x03, + 0xDC, + 0x03, + 0xDC, + 0x03, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xD0, + 0x00, + 0xF0, + 0x00, + 0xF0, + 0x00, + + /* @900 'V' (12 pixels wide) */ + 0x1E, + 0x07, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x92, + 0x0D, + 0xA6, + 0x0E, + 0xA4, + 0x0E, + 0xA4, + 0x0E, + 0xE4, + 0x06, + 0x6C, + 0x06, + 0x68, + 0x06, + 0x68, + 0x02, + 0x18, + 0x03, + 0x10, + 0x03, + 0x10, + 0x01, + 0x90, + 0x01, + 0x90, + 0x01, + 0xE0, + 0x01, + 0xE0, + 0x01, + + /* @936 'W' (12 pixels wide) */ + 0x1E, + 0x07, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0x12, + 0x0D, + 0xF2, + 0x0D, + 0x92, + 0x0D, + 0x12, + 0x0D, + 0x62, + 0x0C, + 0x62, + 0x0C, + 0xE2, + 0x0C, + 0xE2, + 0x0C, + 0xB2, + 0x0D, + 0x3E, + 0x0F, + 0x1C, + 0x0F, + + /* @972 'X' (12 pixels wide) */ + 0x1E, + 0x07, + 0x12, + 0x0D, + 0xB2, + 0x0D, + 0xA6, + 0x0E, + 0xE4, + 0x0E, + 0x6C, + 0x0E, + 0x18, + 0x07, + 0x98, + 0x07, + 0x90, + 0x03, + 0x10, + 0x01, + 0x68, + 0x02, + 0xE4, + 0x02, + 0xE4, + 0x06, + 0xE6, + 0x06, + 0xB2, + 0x0D, + 0x32, + 0x0D, + 0x1E, + 0x0F, + 0x1C, + 0x0E, + + /* @1008 'Y' (12 pixels wide) */ + 0x1E, + 0x07, + 0x12, + 0x0D, + 0xB2, + 0x0D, + 0xA6, + 0x0E, + 0xE4, + 0x0E, + 0x6C, + 0x0E, + 0x68, + 0x06, + 0x18, + 0x07, + 0x18, + 0x03, + 0x90, + 0x03, + 0x90, + 0x01, + 0x90, + 0x01, + 0xA0, + 0x01, + 0xA0, + 0x01, + 0xA0, + 0x01, + 0xE0, + 0x01, + 0xE0, + 0x01, + 0xE0, + 0x01, +}; + +/* Character descriptors for Karma Future 14pt */ +/* { [Char width in bits], [Offset into karmaFuture_14ptCharBitmaps in bytes] } */ +const FONT_CHAR_INFO karmaFuture_14ptDescriptors[] = { + {12, 0}, /* - */ + {0, 0}, /* . */ + {0, 0}, /* / */ + {12, 36}, /* 0 */ + {12, 72}, /* 1 */ + {12, 108}, /* 2 */ + {12, 144}, /* 3 */ + {12, 180}, /* 4 */ + {12, 216}, /* 5 */ + {12, 252}, /* 6 */ + {12, 288}, /* 7 */ + {12, 324}, /* 8 */ + {12, 360}, /* 9 */ + {0, 0}, /* : */ + {0, 0}, /* ; */ + {0, 0}, /* < */ + {0, 0}, /* = */ + {0, 0}, /* > */ + {0, 0}, /* ? */ + {0, 0}, /* @ */ + {0, 0}, /* A */ + {12, 396}, /* B */ + {12, 432}, /* C */ + {12, 468}, /* D */ + {0, 0}, /* E */ + {12, 504}, /* F */ + {12, 540}, /* G */ + {12, 576}, /* H */ + {0, 0}, /* I */ + {12, 612}, /* J */ + {12, 648}, /* K */ + {0, 0}, /* L */ + {12, 684}, /* M */ + {12, 720}, /* N */ + {0, 0}, /* O */ + {12, 756}, /* P */ + {12, 792}, /* Q */ + {12, 828}, /* R */ + {0, 0}, /* S */ + {12, 864}, /* T */ + {0, 0}, /* U */ + {12, 900}, /* V */ + {12, 936}, /* W */ + {12, 972}, /* X */ + {12, 1008}, /* Y */ +}; + +/* Font information for Karma Future 14pt */ +const FONT_INFO karmaFuture_14ptFontInfo = { + 18, /* Character height */ + '-', /* Start character */ + 'Y', /* End character */ + 2, /* Width, in pixels, of space character */ + karmaFuture_14ptDescriptors, /* Character descriptor array */ + karmaFuture_14ptBitmaps, /* Character bitmap array */ +}; diff --git a/applications/external/totp/ui/fonts/karma_future/karma_future.h b/applications/external/totp/ui/fonts/karma_future/karma_future.h new file mode 100644 index 0000000000..3a6352ef18 --- /dev/null +++ b/applications/external/totp/ui/fonts/karma_future/karma_future.h @@ -0,0 +1,8 @@ +#pragma once + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +#include "../font_info.h" + +/* Font data for Karma Future 14pt */ +extern const FONT_INFO karmaFuture_14ptFontInfo; diff --git a/applications/external/totp/ui/fonts/mode-nine/mode_nine.c b/applications/external/totp/ui/fonts/mode_nine/mode_nine.c similarity index 100% rename from applications/external/totp/ui/fonts/mode-nine/mode_nine.c rename to applications/external/totp/ui/fonts/mode_nine/mode_nine.c diff --git a/applications/external/totp/ui/fonts/mode-nine/mode_nine.h b/applications/external/totp/ui/fonts/mode_nine/mode_nine.h similarity index 100% rename from applications/external/totp/ui/fonts/mode-nine/mode_nine.h rename to applications/external/totp/ui/fonts/mode_nine/mode_nine.h diff --git a/applications/external/totp/ui/fonts/redhat_mono/redhat_mono.c b/applications/external/totp/ui/fonts/redhat_mono/redhat_mono.c new file mode 100644 index 0000000000..77f639d4aa --- /dev/null +++ b/applications/external/totp/ui/fonts/redhat_mono/redhat_mono.c @@ -0,0 +1,1057 @@ +#include "redhat_mono.h" +#include + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +/* +** Font data for Red Hat Mono 16pt +*/ + +/* Character bitmaps for Red Hat Mono 16pt */ +const uint8_t redHatMono_16ptBitmaps[] = { + /* @0 '-' (12 pixels wide) */ + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0xF8, + 0x03, + 0xF8, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + + /* @32 '0' (12 pixels wide) */ + 0xF0, + 0x00, + 0xF8, + 0x03, + 0x1C, + 0x07, + 0x0E, + 0x07, + 0x8E, + 0x07, + 0x86, + 0x0E, + 0xC6, + 0x0C, + 0x66, + 0x0C, + 0x66, + 0x0C, + 0x36, + 0x0E, + 0x36, + 0x0E, + 0x1E, + 0x06, + 0x1C, + 0x07, + 0xF8, + 0x03, + 0xF0, + 0x01, + 0x00, + 0x00, + + /* @64 '1' (12 pixels wide) */ + 0x40, + 0x00, + 0x78, + 0x00, + 0x7E, + 0x00, + 0x66, + 0x00, + 0x60, + 0x00, + 0x60, + 0x00, + 0x60, + 0x00, + 0x60, + 0x00, + 0x60, + 0x00, + 0x60, + 0x00, + 0x60, + 0x00, + 0x60, + 0x00, + 0x60, + 0x00, + 0xFE, + 0x07, + 0xFE, + 0x07, + 0x00, + 0x00, + + /* @96 '2' (12 pixels wide) */ + 0xF0, + 0x01, + 0xFC, + 0x03, + 0x0E, + 0x07, + 0x04, + 0x06, + 0x00, + 0x06, + 0x00, + 0x07, + 0x00, + 0x03, + 0x80, + 0x03, + 0xC0, + 0x01, + 0xE0, + 0x00, + 0x70, + 0x00, + 0x38, + 0x00, + 0x1C, + 0x00, + 0xFE, + 0x07, + 0xFE, + 0x07, + 0x00, + 0x00, + + /* @128 '3' (12 pixels wide) */ + 0xF0, + 0x00, + 0xFC, + 0x03, + 0x0E, + 0x07, + 0x04, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x80, + 0x03, + 0xE0, + 0x00, + 0xE0, + 0x03, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x0E, + 0x06, + 0x07, + 0xFE, + 0x07, + 0xF8, + 0x01, + 0x00, + 0x00, + + /* @160 '4' (12 pixels wide) */ + 0x00, + 0x03, + 0x80, + 0x03, + 0xC0, + 0x03, + 0xE0, + 0x03, + 0x70, + 0x03, + 0x30, + 0x03, + 0x18, + 0x03, + 0x0C, + 0x03, + 0x0E, + 0x03, + 0xFF, + 0x0F, + 0xFF, + 0x0F, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x03, + 0x00, + 0x00, + + /* @192 '5' (12 pixels wide) */ + 0xFC, + 0x07, + 0xFC, + 0x07, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0xFC, + 0x01, + 0xFE, + 0x07, + 0x00, + 0x07, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x06, + 0x07, + 0xFE, + 0x03, + 0xF8, + 0x01, + 0x00, + 0x00, + + /* @224 '6' (12 pixels wide) */ + 0xE0, + 0x03, + 0xF8, + 0x07, + 0x3C, + 0x06, + 0x0C, + 0x00, + 0x0E, + 0x00, + 0x06, + 0x00, + 0xE6, + 0x03, + 0xFE, + 0x07, + 0x0E, + 0x0E, + 0x06, + 0x0C, + 0x06, + 0x0C, + 0x0E, + 0x0E, + 0x1C, + 0x06, + 0xF8, + 0x07, + 0xF0, + 0x03, + 0x00, + 0x00, + + /* @256 '7' (12 pixels wide) */ + 0xFE, + 0x0F, + 0xFE, + 0x0F, + 0x00, + 0x0E, + 0x00, + 0x06, + 0x00, + 0x07, + 0x00, + 0x03, + 0x80, + 0x01, + 0xC0, + 0x01, + 0xC0, + 0x00, + 0xE0, + 0x00, + 0x60, + 0x00, + 0x70, + 0x00, + 0x30, + 0x00, + 0x38, + 0x00, + 0x1C, + 0x00, + 0x00, + 0x00, + + /* @288 '8' (12 pixels wide) */ + 0xF0, + 0x01, + 0xFC, + 0x03, + 0x1C, + 0x07, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0C, + 0x06, + 0xBC, + 0x03, + 0xF0, + 0x01, + 0x1C, + 0x07, + 0x0E, + 0x06, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x0E, + 0x06, + 0xFC, + 0x07, + 0xF8, + 0x03, + 0x00, + 0x00, + + /* @320 '9' (12 pixels wide) */ + 0xF8, + 0x01, + 0xFC, + 0x03, + 0x0C, + 0x07, + 0x0E, + 0x0E, + 0x06, + 0x0C, + 0x06, + 0x0C, + 0x0E, + 0x0E, + 0xFC, + 0x0F, + 0xF8, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0E, + 0x00, + 0x06, + 0x8C, + 0x07, + 0xFC, + 0x03, + 0xF8, + 0x00, + 0x00, + 0x00, + + /* @352 'B' (12 pixels wide) */ + 0xFC, + 0x00, + 0xFC, + 0x03, + 0x8C, + 0x07, + 0x0C, + 0x06, + 0x0C, + 0x06, + 0x0C, + 0x07, + 0xFC, + 0x03, + 0xFC, + 0x01, + 0x8C, + 0x07, + 0x0C, + 0x06, + 0x0C, + 0x0E, + 0x0C, + 0x0E, + 0x0C, + 0x07, + 0xFC, + 0x07, + 0xFC, + 0x01, + 0x00, + 0x00, + + /* @384 'C' (12 pixels wide) */ + 0xF0, + 0x01, + 0xF8, + 0x03, + 0xBC, + 0x07, + 0x0C, + 0x06, + 0x0E, + 0x0E, + 0x0E, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x1C, + 0x07, + 0xF8, + 0x03, + 0xF0, + 0x01, + 0x00, + 0x00, + + /* @416 'D' (12 pixels wide) */ + 0x7E, + 0x00, + 0xFE, + 0x01, + 0xCE, + 0x03, + 0x0E, + 0x07, + 0x0E, + 0x06, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0C, + 0x0E, + 0x0C, + 0x0E, + 0x0C, + 0x06, + 0x0C, + 0x07, + 0x8C, + 0x07, + 0xFC, + 0x03, + 0xFC, + 0x00, + 0x00, + 0x00, + + /* @448 'F' (12 pixels wide) */ + 0xFC, + 0x0F, + 0xFC, + 0x0F, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0xFC, + 0x01, + 0xFC, + 0x01, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x00, + 0x00, + + /* @480 'G' (12 pixels wide) */ + 0xF0, + 0x01, + 0xF8, + 0x03, + 0xBC, + 0x07, + 0x0C, + 0x06, + 0x0E, + 0x0E, + 0x06, + 0x00, + 0x06, + 0x00, + 0x86, + 0x0F, + 0x86, + 0x0F, + 0x06, + 0x0C, + 0x0E, + 0x0E, + 0x0E, + 0x06, + 0x1C, + 0x07, + 0xF8, + 0x03, + 0xF0, + 0x01, + 0x00, + 0x00, + + /* @512 'H' (12 pixels wide) */ + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0xFE, + 0x07, + 0xFE, + 0x07, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x00, + 0x00, + + /* @544 'J' (12 pixels wide) */ + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x00, + 0x06, + 0x04, + 0x06, + 0x07, + 0x07, + 0x8E, + 0x07, + 0xFC, + 0x03, + 0xF8, + 0x01, + 0x00, + 0x00, + + /* @576 'K' (12 pixels wide) */ + 0x0E, + 0x0E, + 0x0E, + 0x07, + 0x0E, + 0x03, + 0x8E, + 0x01, + 0xCE, + 0x01, + 0xEE, + 0x00, + 0x7E, + 0x00, + 0x3E, + 0x00, + 0x7E, + 0x00, + 0xEE, + 0x00, + 0xCE, + 0x01, + 0x8E, + 0x03, + 0x8E, + 0x03, + 0x0E, + 0x07, + 0x0E, + 0x0E, + 0x00, + 0x00, + + /* @608 'M' (12 pixels wide) */ + 0x0E, + 0x0E, + 0x0E, + 0x0F, + 0x1E, + 0x0F, + 0x9E, + 0x0F, + 0xB6, + 0x0F, + 0xB6, + 0x0F, + 0xF6, + 0x0E, + 0xE6, + 0x0E, + 0x66, + 0x0E, + 0x46, + 0x0E, + 0x26, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x00, + 0x00, + + /* @640 'N' (12 pixels wide) */ + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x1E, + 0x06, + 0x3E, + 0x06, + 0x3E, + 0x06, + 0x76, + 0x06, + 0x66, + 0x06, + 0xE6, + 0x06, + 0xC6, + 0x06, + 0xC6, + 0x07, + 0x86, + 0x07, + 0x86, + 0x07, + 0x06, + 0x07, + 0x06, + 0x07, + 0x06, + 0x06, + 0x00, + 0x00, + + /* @672 'P' (12 pixels wide) */ + 0xFC, + 0x00, + 0xFC, + 0x03, + 0x8C, + 0x07, + 0x0C, + 0x0E, + 0x0C, + 0x0E, + 0x0C, + 0x0E, + 0x0C, + 0x06, + 0xFC, + 0x07, + 0xFC, + 0x03, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x00, + 0x00, + + /* @704 'Q' (12 pixels wide) */ + 0xF0, + 0x00, + 0xF8, + 0x03, + 0x9C, + 0x07, + 0x0E, + 0x07, + 0x0E, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0x06, + 0x0E, + 0xEE, + 0x0E, + 0xCE, + 0x07, + 0x9C, + 0x07, + 0xFC, + 0x07, + 0xF0, + 0x07, + 0x00, + 0x0A, + + /* @736 'R' (12 pixels wide) */ + 0xFC, + 0x00, + 0xFC, + 0x03, + 0x8C, + 0x07, + 0x0C, + 0x06, + 0x0C, + 0x0E, + 0x0C, + 0x0E, + 0x0C, + 0x07, + 0xFC, + 0x07, + 0xFC, + 0x01, + 0x8C, + 0x01, + 0x8C, + 0x03, + 0x0C, + 0x03, + 0x0C, + 0x07, + 0x0C, + 0x06, + 0x0C, + 0x0E, + 0x00, + 0x00, + + /* @768 'T' (12 pixels wide) */ + 0xFF, + 0x0F, + 0xFF, + 0x0F, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0x00, + 0x00, + + /* @800 'V' (12 pixels wide) */ + 0x07, + 0x0C, + 0x06, + 0x0C, + 0x06, + 0x0E, + 0x0E, + 0x06, + 0x0C, + 0x06, + 0x0C, + 0x07, + 0x1C, + 0x03, + 0x1C, + 0x03, + 0x98, + 0x03, + 0x98, + 0x03, + 0xB8, + 0x01, + 0xB0, + 0x01, + 0xF0, + 0x01, + 0xF0, + 0x00, + 0xE0, + 0x00, + 0x00, + 0x00, + + /* @832 'W' (12 pixels wide) */ + 0x67, + 0x0C, + 0xE6, + 0x0C, + 0xE6, + 0x0C, + 0xE6, + 0x0C, + 0xE6, + 0x0C, + 0xF6, + 0x0C, + 0xB6, + 0x0E, + 0xB6, + 0x07, + 0xB6, + 0x07, + 0x96, + 0x07, + 0x9C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x1C, + 0x07, + 0x0C, + 0x07, + 0x00, + 0x00, + + /* @864 'X' (12 pixels wide) */ + 0x0E, + 0x0E, + 0x0E, + 0x06, + 0x1C, + 0x07, + 0x98, + 0x03, + 0xB8, + 0x01, + 0xF0, + 0x01, + 0xF0, + 0x00, + 0xE0, + 0x00, + 0xF0, + 0x00, + 0xF0, + 0x01, + 0xB8, + 0x03, + 0x9C, + 0x03, + 0x0C, + 0x07, + 0x0E, + 0x06, + 0x07, + 0x0E, + 0x00, + 0x00, + + /* @896 'Y' (12 pixels wide) */ + 0x07, + 0x0C, + 0x0E, + 0x0E, + 0x0E, + 0x06, + 0x1C, + 0x07, + 0x18, + 0x03, + 0xB8, + 0x03, + 0xF0, + 0x01, + 0xF0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0xE0, + 0x00, + 0x00, + 0x00, +}; + +/* Character descriptors for Red Hat Mono 16pt */ +/* { [Char width in bits], [Offset into redHatMono_16ptCharBitmaps in bytes] } */ +const FONT_CHAR_INFO redHatMono_16ptDescriptors[] = { + {12, 0}, /* - */ + {0, 0}, /* . */ + {0, 0}, /* / */ + {12, 32}, /* 0 */ + {12, 64}, /* 1 */ + {12, 96}, /* 2 */ + {12, 128}, /* 3 */ + {12, 160}, /* 4 */ + {12, 192}, /* 5 */ + {12, 224}, /* 6 */ + {12, 256}, /* 7 */ + {12, 288}, /* 8 */ + {12, 320}, /* 9 */ + {0, 0}, /* : */ + {0, 0}, /* ; */ + {0, 0}, /* < */ + {0, 0}, /* = */ + {0, 0}, /* > */ + {0, 0}, /* ? */ + {0, 0}, /* @ */ + {0, 0}, /* A */ + {12, 352}, /* B */ + {12, 384}, /* C */ + {12, 416}, /* D */ + {0, 0}, /* E */ + {12, 448}, /* F */ + {12, 480}, /* G */ + {12, 512}, /* H */ + {0, 0}, /* I */ + {12, 544}, /* J */ + {12, 576}, /* K */ + {0, 0}, /* L */ + {12, 608}, /* M */ + {12, 640}, /* N */ + {0, 0}, /* O */ + {12, 672}, /* P */ + {12, 704}, /* Q */ + {12, 736}, /* R */ + {0, 0}, /* S */ + {12, 768}, /* T */ + {0, 0}, /* U */ + {12, 800}, /* V */ + {12, 832}, /* W */ + {12, 864}, /* X */ + {12, 896}, /* Y */ +}; + +/* Font information for Red Hat Mono 16pt */ +const FONT_INFO redHatMono_16ptFontInfo = { + 16, /* Character height */ + '-', /* Start character */ + 'Y', /* End character */ + 2, /* Width, in pixels, of space character */ + redHatMono_16ptDescriptors, /* Character descriptor array */ + redHatMono_16ptBitmaps, /* Character bitmap array */ +}; diff --git a/applications/external/totp/ui/fonts/redhat_mono/redhat_mono.h b/applications/external/totp/ui/fonts/redhat_mono/redhat_mono.h new file mode 100644 index 0000000000..ac9214d6b1 --- /dev/null +++ b/applications/external/totp/ui/fonts/redhat_mono/redhat_mono.h @@ -0,0 +1,8 @@ +#pragma once + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +#include "../font_info.h" + +/* Font data for Redhat Mono 16pt */ +extern const FONT_INFO redHatMono_16ptFontInfo; \ No newline at end of file diff --git a/applications/external/totp/ui/fonts/zector/zector.c b/applications/external/totp/ui/fonts/zector/zector.c new file mode 100644 index 0000000000..f49d8b3064 --- /dev/null +++ b/applications/external/totp/ui/fonts/zector/zector.c @@ -0,0 +1,1056 @@ +#include "zector.h" + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +/* +** Font data for Zector 18pt +*/ + +/* Character bitmaps for Zector 18pt */ +const uint8_t zector_18ptBitmaps[] = { + /* @0 '-' (9 pixels wide) */ + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0xFF, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + + /* @32 '0' (9 pixels wide) */ + 0x3C, + 0x00, + 0xC2, + 0x00, + 0x83, + 0x00, + 0x85, + 0x00, + 0x85, + 0x00, + 0x89, + 0x00, + 0x89, + 0x00, + 0x91, + 0x00, + 0x91, + 0x00, + 0xA1, + 0x00, + 0xA1, + 0x00, + 0xC1, + 0x00, + 0xC1, + 0x00, + 0x81, + 0x00, + 0x42, + 0x00, + 0x3C, + 0x00, + + /* @64 '1' (9 pixels wide) */ + 0x10, + 0x00, + 0x18, + 0x00, + 0x18, + 0x00, + 0x14, + 0x00, + 0x14, + 0x00, + 0x12, + 0x00, + 0x12, + 0x00, + 0x11, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0xFF, + 0x00, + + /* @96 '2' (9 pixels wide) */ + 0x3C, + 0x00, + 0x42, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x40, + 0x00, + 0x20, + 0x00, + 0x20, + 0x00, + 0x10, + 0x00, + 0x08, + 0x00, + 0x08, + 0x00, + 0x04, + 0x00, + 0x02, + 0x00, + 0x02, + 0x00, + 0xFF, + 0x00, + + /* @128 '3' (9 pixels wide) */ + 0xFF, + 0x01, + 0x80, + 0x00, + 0x80, + 0x00, + 0x40, + 0x00, + 0x40, + 0x00, + 0x20, + 0x00, + 0x20, + 0x00, + 0x10, + 0x00, + 0x60, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x00, + 0x01, + 0x01, + 0x01, + 0x81, + 0x00, + 0x42, + 0x00, + 0x3C, + 0x00, + + /* @160 '4' (9 pixels wide) */ + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0xFF, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + + /* @192 '5' (9 pixels wide) */ + 0xFF, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x3F, + 0x00, + 0x40, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0xC2, + 0x00, + 0x3C, + 0x00, + + /* @224 '6' (9 pixels wide) */ + 0x3C, + 0x00, + 0x42, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x3D, + 0x00, + 0x43, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0xC2, + 0x00, + 0x3C, + 0x00, + + /* @256 '7' (9 pixels wide) */ + 0xFF, + 0x01, + 0x80, + 0x00, + 0x80, + 0x00, + 0x40, + 0x00, + 0x40, + 0x00, + 0x20, + 0x00, + 0x20, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x08, + 0x00, + 0x08, + 0x00, + 0x04, + 0x00, + 0x04, + 0x00, + 0x02, + 0x00, + 0x02, + 0x00, + 0x01, + 0x00, + + /* @288 '8' (9 pixels wide) */ + 0x3C, + 0x00, + 0xC2, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x42, + 0x00, + 0x3C, + 0x00, + 0x42, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x42, + 0x00, + 0x3C, + 0x00, + + /* @320 '9' (9 pixels wide) */ + 0x3C, + 0x00, + 0x42, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0xC2, + 0x00, + 0xBC, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x42, + 0x00, + 0x3C, + 0x00, + + /* @352 'B' (9 pixels wide) */ + 0x3F, + 0x00, + 0xC1, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x41, + 0x00, + 0x3F, + 0x00, + 0x41, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x41, + 0x00, + 0x3F, + 0x00, + + /* @384 'C' (9 pixels wide) */ + 0x3C, + 0x00, + 0x42, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x42, + 0x00, + 0x3C, + 0x00, + + /* @416 'D' (9 pixels wide) */ + 0x3F, + 0x00, + 0x41, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x41, + 0x00, + 0x3F, + 0x00, + + /* @448 'F' (9 pixels wide) */ + 0xFF, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0xFF, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + + /* @480 'G' (9 pixels wide) */ + 0x3C, + 0x00, + 0xC2, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0xF1, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x42, + 0x00, + 0x3C, + 0x00, + + /* @512 'H' (9 pixels wide) */ + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0xFF, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + + /* @544 'J' (9 pixels wide) */ + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x80, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x42, + 0x00, + 0x3C, + 0x00, + + /* @576 'K' (9 pixels wide) */ + 0x81, + 0x00, + 0xC1, + 0x00, + 0x61, + 0x00, + 0x21, + 0x00, + 0x11, + 0x00, + 0x09, + 0x00, + 0x05, + 0x00, + 0x03, + 0x00, + 0x01, + 0x00, + 0x03, + 0x00, + 0x05, + 0x00, + 0x09, + 0x00, + 0x11, + 0x00, + 0x21, + 0x00, + 0x41, + 0x00, + 0x81, + 0x00, + + /* @608 'M' (9 pixels wide) */ + 0x81, + 0x00, + 0x81, + 0x00, + 0x83, + 0x00, + 0xC3, + 0x00, + 0xC5, + 0x00, + 0xA5, + 0x00, + 0xA9, + 0x00, + 0x91, + 0x00, + 0x91, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + + /* @640 'N' (9 pixels wide) */ + 0x81, + 0x00, + 0x81, + 0x00, + 0x83, + 0x00, + 0x83, + 0x00, + 0x85, + 0x00, + 0x85, + 0x00, + 0x89, + 0x00, + 0x89, + 0x00, + 0x91, + 0x00, + 0xA1, + 0x00, + 0xA1, + 0x00, + 0xC1, + 0x00, + 0xC1, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + + /* @672 'P' (9 pixels wide) */ + 0x3F, + 0x00, + 0x41, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x41, + 0x00, + 0x3F, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + 0x01, + 0x00, + + /* @704 'Q' (9 pixels wide) */ + 0x3C, + 0x00, + 0x42, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x91, + 0x00, + 0xA1, + 0x00, + 0xC2, + 0x00, + 0xBC, + 0x00, + + /* @736 'R' (9 pixels wide) */ + 0x3F, + 0x00, + 0x41, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x41, + 0x00, + 0x3F, + 0x00, + 0x03, + 0x00, + 0x05, + 0x00, + 0x09, + 0x00, + 0x11, + 0x00, + 0x21, + 0x00, + 0x41, + 0x00, + 0x81, + 0x00, + + /* @768 'T' (9 pixels wide) */ + 0xFF, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + + /* @800 'V' (9 pixels wide) */ + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x82, + 0x00, + 0x42, + 0x00, + 0x44, + 0x00, + 0x24, + 0x00, + 0x28, + 0x00, + 0x18, + 0x00, + 0x10, + 0x00, + + /* @832 'W' (9 pixels wide) */ + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + 0x91, + 0x00, + 0x91, + 0x00, + 0x99, + 0x00, + 0xA9, + 0x00, + 0xA5, + 0x00, + 0xC5, + 0x00, + 0x83, + 0x00, + 0x81, + 0x00, + 0x81, + 0x00, + + /* @864 'X' (9 pixels wide) */ + 0x81, + 0x00, + 0x82, + 0x00, + 0x82, + 0x00, + 0x44, + 0x00, + 0x44, + 0x00, + 0x28, + 0x00, + 0x28, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x28, + 0x00, + 0x28, + 0x00, + 0x44, + 0x00, + 0x44, + 0x00, + 0x82, + 0x00, + 0x82, + 0x00, + 0x81, + 0x00, + + /* @896 'Y' (9 pixels wide) */ + 0x81, + 0x00, + 0x82, + 0x00, + 0x82, + 0x00, + 0x44, + 0x00, + 0x44, + 0x00, + 0x28, + 0x00, + 0x28, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, + 0x10, + 0x00, +}; + +/* Character descriptors for Zector 18pt */ +/* { [Char width in bits], [Offset into zector_18ptCharBitmaps in bytes] } */ +const FONT_CHAR_INFO zector_18ptDescriptors[] = { + {9, 0}, /* - */ + {0, 0}, /* . */ + {0, 0}, /* / */ + {9, 32}, /* 0 */ + {9, 64}, /* 1 */ + {9, 96}, /* 2 */ + {9, 128}, /* 3 */ + {9, 160}, /* 4 */ + {9, 192}, /* 5 */ + {9, 224}, /* 6 */ + {9, 256}, /* 7 */ + {9, 288}, /* 8 */ + {9, 320}, /* 9 */ + {0, 0}, /* : */ + {0, 0}, /* ; */ + {0, 0}, /* < */ + {0, 0}, /* = */ + {0, 0}, /* > */ + {0, 0}, /* ? */ + {0, 0}, /* @ */ + {0, 0}, /* A */ + {9, 352}, /* B */ + {9, 384}, /* C */ + {9, 416}, /* D */ + {0, 0}, /* E */ + {9, 448}, /* F */ + {9, 480}, /* G */ + {9, 512}, /* H */ + {0, 0}, /* I */ + {9, 544}, /* J */ + {9, 576}, /* K */ + {0, 0}, /* L */ + {9, 608}, /* M */ + {9, 640}, /* N */ + {0, 0}, /* O */ + {9, 672}, /* P */ + {9, 704}, /* Q */ + {9, 736}, /* R */ + {0, 0}, /* S */ + {9, 768}, /* T */ + {0, 0}, /* U */ + {9, 800}, /* V */ + {9, 832}, /* W */ + {9, 864}, /* X */ + {9, 896}, /* Y */ +}; + +/* Font information for Zector 18pt */ +const FONT_INFO zector_18ptFontInfo = { + 16, /* Character height */ + '-', /* Start character */ + 'Y', /* End character */ + 2, /* Width, in pixels, of space character */ + zector_18ptDescriptors, /* Character descriptor array */ + zector_18ptBitmaps, /* Character bitmap array */ +}; diff --git a/applications/external/totp/ui/fonts/zector/zector.h b/applications/external/totp/ui/fonts/zector/zector.h new file mode 100644 index 0000000000..2a5cf59079 --- /dev/null +++ b/applications/external/totp/ui/fonts/zector/zector.h @@ -0,0 +1,8 @@ +#pragma once + +/* GENERATED BY https://github.com/pavius/the-dot-factory */ + +#include "../font_info.h" + +/* Font information for Zector 18pt */ +extern const FONT_INFO zector_18ptFontInfo; \ No newline at end of file diff --git a/applications/external/totp/ui/scenes/add_new_token/totp_input_text.c b/applications/external/totp/ui/scenes/add_new_token/totp_input_text.c index bbe0b77262..5eb1231d9e 100644 --- a/applications/external/totp/ui/scenes/add_new_token/totp_input_text.c +++ b/applications/external/totp/ui/scenes/add_new_token/totp_input_text.c @@ -29,7 +29,7 @@ void view_unlock_model(View* view) { static void commit_text_input_callback(void* context) { InputTextSceneState* text_input_state = (InputTextSceneState*)context; - if(text_input_state->callback != 0) { + if(text_input_state->callback != NULL) { InputTextSceneCallbackResult* result = malloc(sizeof(InputTextSceneCallbackResult)); furi_check(result != NULL); result->user_input_length = diff --git a/applications/external/totp/ui/scenes/add_new_token/totp_scene_add_new_token.c b/applications/external/totp/ui/scenes/add_new_token/totp_scene_add_new_token.c index d525e33996..327185cf76 100644 --- a/applications/external/totp/ui/scenes/add_new_token/totp_scene_add_new_token.c +++ b/applications/external/totp/ui/scenes/add_new_token/totp_scene_add_new_token.c @@ -36,7 +36,7 @@ typedef struct { InputTextSceneContext* token_name_input_context; InputTextSceneContext* token_secret_input_context; InputTextSceneState* input_state; - uint32_t input_started_at; + bool text_input_mode; int16_t screen_y_offset; TokenHashAlgo algo; uint8_t digits_count_index; @@ -56,7 +56,7 @@ static void on_token_name_user_comitted(InputTextSceneCallbackResult* result) { free(scene_state->token_name); scene_state->token_name = result->user_input; scene_state->token_name_length = result->user_input_length; - scene_state->input_started_at = 0; + scene_state->text_input_mode = false; free(result); } @@ -65,7 +65,7 @@ static void on_token_secret_user_comitted(InputTextSceneCallbackResult* result) free(scene_state->token_secret); scene_state->token_secret = result->user_input; scene_state->token_secret_length = result->user_input_length; - scene_state->input_started_at = 0; + scene_state->text_input_mode = false; free(result); } @@ -127,8 +127,8 @@ void totp_scene_add_new_token_activate(PluginState* plugin_state) { } void totp_scene_add_new_token_render(Canvas* const canvas, PluginState* plugin_state) { - SceneState* scene_state = (SceneState*)plugin_state->current_scene_state; - if(scene_state->input_started_at > 0) { + SceneState* scene_state = plugin_state->current_scene_state; + if(scene_state->text_input_mode) { totp_input_text_render(canvas, scene_state->input_state); return; } @@ -200,63 +200,81 @@ bool totp_scene_add_new_token_handle_event(PluginEvent* const event, PluginState return true; } - SceneState* scene_state = (SceneState*)plugin_state->current_scene_state; - if(scene_state->input_started_at > 0 && - furi_get_tick() - scene_state->input_started_at > 300) { - return totp_input_text_handle_event(event, scene_state->input_state); - } + SceneState* scene_state = plugin_state->current_scene_state; if(event->input.type == InputTypeLong && event->input.key == InputKeyBack) { - return false; + if(scene_state->text_input_mode) { + scene_state->text_input_mode = false; + } else { + return false; + } } - if(event->input.type != InputTypePress) { - return true; + if(scene_state->text_input_mode) { + if(event->input.type == InputTypeShort && event->input.key == InputKeyBack) { + PluginEvent long_back_cb_evt = { + .type = event->type, .input.key = InputKeyBack, .input.type = InputTypeLong}; + return totp_input_text_handle_event(&long_back_cb_evt, scene_state->input_state); + } + + return totp_input_text_handle_event(event, scene_state->input_state); } - switch(event->input.key) { - case InputKeyUp: - totp_roll_value_uint8_t( - &scene_state->selected_control, - -1, - TokenNameTextBox, - ConfirmButton, - RollOverflowBehaviorStop); - update_screen_y_offset(scene_state); - break; - case InputKeyDown: - totp_roll_value_uint8_t( - &scene_state->selected_control, - 1, - TokenNameTextBox, - ConfirmButton, - RollOverflowBehaviorStop); - update_screen_y_offset(scene_state); - break; - case InputKeyRight: - if(scene_state->selected_control == TokenAlgoSelect) { - totp_roll_value_uint8_t(&scene_state->algo, 1, SHA1, STEAM, RollOverflowBehaviorRoll); - } else if(scene_state->selected_control == TokenLengthSelect) { + if(event->input.type == InputTypePress) { + switch(event->input.key) { + case InputKeyUp: totp_roll_value_uint8_t( - &scene_state->digits_count_index, 1, 0, 2, RollOverflowBehaviorRoll); - } else if(scene_state->selected_control == TokenDurationSelect) { - totp_roll_value_uint8_t(&scene_state->duration, 15, 15, 255, RollOverflowBehaviorStop); - update_duration_text(scene_state); - } - break; - case InputKeyLeft: - if(scene_state->selected_control == TokenAlgoSelect) { - totp_roll_value_uint8_t(&scene_state->algo, -1, SHA1, STEAM, RollOverflowBehaviorRoll); - } else if(scene_state->selected_control == TokenLengthSelect) { - totp_roll_value_uint8_t( - &scene_state->digits_count_index, -1, 0, 2, RollOverflowBehaviorRoll); - } else if(scene_state->selected_control == TokenDurationSelect) { + &scene_state->selected_control, + -1, + TokenNameTextBox, + ConfirmButton, + RollOverflowBehaviorStop); + update_screen_y_offset(scene_state); + break; + case InputKeyDown: totp_roll_value_uint8_t( - &scene_state->duration, -15, 15, 255, RollOverflowBehaviorStop); - update_duration_text(scene_state); + &scene_state->selected_control, + 1, + TokenNameTextBox, + ConfirmButton, + RollOverflowBehaviorStop); + update_screen_y_offset(scene_state); + break; + case InputKeyRight: + if(scene_state->selected_control == TokenAlgoSelect) { + totp_roll_value_uint8_t( + &scene_state->algo, 1, SHA1, STEAM, RollOverflowBehaviorRoll); + } else if(scene_state->selected_control == TokenLengthSelect) { + totp_roll_value_uint8_t( + &scene_state->digits_count_index, 1, 0, 2, RollOverflowBehaviorRoll); + } else if(scene_state->selected_control == TokenDurationSelect) { + totp_roll_value_uint8_t( + &scene_state->duration, 15, 15, 255, RollOverflowBehaviorStop); + update_duration_text(scene_state); + } + break; + case InputKeyLeft: + if(scene_state->selected_control == TokenAlgoSelect) { + totp_roll_value_uint8_t( + &scene_state->algo, -1, SHA1, STEAM, RollOverflowBehaviorRoll); + } else if(scene_state->selected_control == TokenLengthSelect) { + totp_roll_value_uint8_t( + &scene_state->digits_count_index, -1, 0, 2, RollOverflowBehaviorRoll); + } else if(scene_state->selected_control == TokenDurationSelect) { + totp_roll_value_uint8_t( + &scene_state->duration, -15, 15, 255, RollOverflowBehaviorStop); + update_duration_text(scene_state); + } + break; + case InputKeyOk: + break; + case InputKeyBack: + totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken); + break; + default: + break; } - break; - case InputKeyOk: + } else if(event->input.type == InputTypeRelease && event->input.key == InputKeyOk) { switch(scene_state->selected_control) { case TokenNameTextBox: if(scene_state->input_state != NULL) { @@ -264,7 +282,8 @@ bool totp_scene_add_new_token_handle_event(PluginEvent* const event, PluginState } scene_state->input_state = totp_input_text_activate(scene_state->token_name_input_context); - scene_state->input_started_at = furi_get_tick(); + + scene_state->text_input_mode = true; break; case TokenSecretTextBox: if(scene_state->input_state != NULL) { @@ -272,7 +291,8 @@ bool totp_scene_add_new_token_handle_event(PluginEvent* const event, PluginState } scene_state->input_state = totp_input_text_activate(scene_state->token_secret_input_context); - scene_state->input_started_at = furi_get_tick(); + + scene_state->text_input_mode = true; break; case TokenAlgoSelect: break; @@ -313,12 +333,6 @@ bool totp_scene_add_new_token_handle_event(PluginEvent* const event, PluginState default: break; } - break; - case InputKeyBack: - totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken); - break; - default: - break; } return true; diff --git a/applications/external/totp/ui/scenes/app_settings/totp_app_settings.c b/applications/external/totp/ui/scenes/app_settings/totp_app_settings.c index 6dcf0dbc90..54659946d2 100644 --- a/applications/external/totp/ui/scenes/app_settings/totp_app_settings.c +++ b/applications/external/totp/ui/scenes/app_settings/totp_app_settings.c @@ -60,17 +60,17 @@ void totp_scene_app_settings_activate(PluginState* plugin_state) { } static void two_digit_to_str(int8_t num, char* str) { - uint8_t index = 0; + char* s = str; if(num < 0) { - str[index++] = '-'; + *(s++) = '-'; num = -num; } uint8_t d1 = (num / 10) % 10; uint8_t d2 = num % 10; - str[index++] = CONVERT_DIGIT_TO_CHAR(d1); - str[index++] = CONVERT_DIGIT_TO_CHAR(d2); - str[index++] = '\0'; + *(s++) = CONVERT_DIGIT_TO_CHAR(d1); + *(s++) = CONVERT_DIGIT_TO_CHAR(d2); + *(s++) = '\0'; } void totp_scene_app_settings_render(Canvas* const canvas, const PluginState* plugin_state) { @@ -183,116 +183,117 @@ bool totp_scene_app_settings_handle_event( } SceneState* scene_state = (SceneState*)plugin_state->current_scene_state; - if(event->input.type != InputTypePress && event->input.type != InputTypeRepeat) { - return true; - } - - switch(event->input.key) { - case InputKeyUp: - totp_roll_value_uint8_t( - &scene_state->selected_control, - -1, - HoursInput, - ConfirmButton, - RollOverflowBehaviorStop); - if(scene_state->selected_control > Vibro) { - scene_state->y_offset = 128; - } else if(scene_state->selected_control > MinutesInput) { - scene_state->y_offset = 64; - } else { - scene_state->y_offset = 0; - } - break; - case InputKeyDown: - totp_roll_value_uint8_t( - &scene_state->selected_control, 1, HoursInput, ConfirmButton, RollOverflowBehaviorStop); - if(scene_state->selected_control > Vibro) { - scene_state->y_offset = 128; - } else if(scene_state->selected_control > MinutesInput) { - scene_state->y_offset = 64; - } else { - scene_state->y_offset = 0; - } - break; - case InputKeyRight: - if(scene_state->selected_control == HoursInput) { - totp_roll_value_int8_t( - &scene_state->tz_offset_hours, 1, -12, 12, RollOverflowBehaviorStop); - } else if(scene_state->selected_control == MinutesInput) { + if(event->input.type == InputTypePress || event->input.type == InputTypeRepeat) { + switch(event->input.key) { + case InputKeyUp: totp_roll_value_uint8_t( - &scene_state->tz_offset_minutes, 15, 0, 45, RollOverflowBehaviorRoll); - } else if(scene_state->selected_control == Sound) { - scene_state->notification_sound = !scene_state->notification_sound; - } else if(scene_state->selected_control == Vibro) { - scene_state->notification_vibro = !scene_state->notification_vibro; - } else if(scene_state->selected_control == BadUsb) { - scene_state->badusb_enabled = !scene_state->badusb_enabled; - } + &scene_state->selected_control, + -1, + HoursInput, + ConfirmButton, + RollOverflowBehaviorStop); + if(scene_state->selected_control > Vibro) { + scene_state->y_offset = 128; + } else if(scene_state->selected_control > MinutesInput) { + scene_state->y_offset = 64; + } else { + scene_state->y_offset = 0; + } + break; + case InputKeyDown: + totp_roll_value_uint8_t( + &scene_state->selected_control, + 1, + HoursInput, + ConfirmButton, + RollOverflowBehaviorStop); + if(scene_state->selected_control > Vibro) { + scene_state->y_offset = 128; + } else if(scene_state->selected_control > MinutesInput) { + scene_state->y_offset = 64; + } else { + scene_state->y_offset = 0; + } + break; + case InputKeyRight: + if(scene_state->selected_control == HoursInput) { + totp_roll_value_int8_t( + &scene_state->tz_offset_hours, 1, -12, 12, RollOverflowBehaviorStop); + } else if(scene_state->selected_control == MinutesInput) { + totp_roll_value_uint8_t( + &scene_state->tz_offset_minutes, 15, 0, 45, RollOverflowBehaviorRoll); + } else if(scene_state->selected_control == Sound) { + scene_state->notification_sound = !scene_state->notification_sound; + } else if(scene_state->selected_control == Vibro) { + scene_state->notification_vibro = !scene_state->notification_vibro; + } else if(scene_state->selected_control == BadUsb) { + scene_state->badusb_enabled = !scene_state->badusb_enabled; + } #ifdef TOTP_BADBT_TYPE_ENABLED - else if(scene_state->selected_control == BadBt) { - scene_state->badbt_enabled = !scene_state->badbt_enabled; - } + else if(scene_state->selected_control == BadBt) { + scene_state->badbt_enabled = !scene_state->badbt_enabled; + } #endif - break; - case InputKeyLeft: - if(scene_state->selected_control == HoursInput) { - totp_roll_value_int8_t( - &scene_state->tz_offset_hours, -1, -12, 12, RollOverflowBehaviorStop); - } else if(scene_state->selected_control == MinutesInput) { - totp_roll_value_uint8_t( - &scene_state->tz_offset_minutes, -15, 0, 45, RollOverflowBehaviorRoll); - } else if(scene_state->selected_control == Sound) { - scene_state->notification_sound = !scene_state->notification_sound; - } else if(scene_state->selected_control == Vibro) { - scene_state->notification_vibro = !scene_state->notification_vibro; - } else if(scene_state->selected_control == BadUsb) { - scene_state->badusb_enabled = !scene_state->badusb_enabled; - } + break; + case InputKeyLeft: + if(scene_state->selected_control == HoursInput) { + totp_roll_value_int8_t( + &scene_state->tz_offset_hours, -1, -12, 12, RollOverflowBehaviorStop); + } else if(scene_state->selected_control == MinutesInput) { + totp_roll_value_uint8_t( + &scene_state->tz_offset_minutes, -15, 0, 45, RollOverflowBehaviorRoll); + } else if(scene_state->selected_control == Sound) { + scene_state->notification_sound = !scene_state->notification_sound; + } else if(scene_state->selected_control == Vibro) { + scene_state->notification_vibro = !scene_state->notification_vibro; + } else if(scene_state->selected_control == BadUsb) { + scene_state->badusb_enabled = !scene_state->badusb_enabled; + } #ifdef TOTP_BADBT_TYPE_ENABLED - else if(scene_state->selected_control == BadBt) { - scene_state->badbt_enabled = !scene_state->badbt_enabled; - } + else if(scene_state->selected_control == BadBt) { + scene_state->badbt_enabled = !scene_state->badbt_enabled; + } #endif - break; - case InputKeyOk: - if(scene_state->selected_control == ConfirmButton) { - plugin_state->timezone_offset = (float)scene_state->tz_offset_hours + - (float)scene_state->tz_offset_minutes / 60.0f; + break; + case InputKeyOk: + break; + case InputKeyBack: { + totp_scene_director_activate_scene(plugin_state, TotpSceneTokenMenu); + break; + } + default: + break; + } + } else if( + event->input.type == InputTypeRelease && event->input.key == InputKeyOk && + scene_state->selected_control == ConfirmButton) { + plugin_state->timezone_offset = + (float)scene_state->tz_offset_hours + (float)scene_state->tz_offset_minutes / 60.0f; - plugin_state->notification_method = - (scene_state->notification_sound ? NotificationMethodSound : - NotificationMethodNone) | - (scene_state->notification_vibro ? NotificationMethodVibro : - NotificationMethodNone); + plugin_state->notification_method = + (scene_state->notification_sound ? NotificationMethodSound : NotificationMethodNone) | + (scene_state->notification_vibro ? NotificationMethodVibro : NotificationMethodNone); - plugin_state->automation_method = - scene_state->badusb_enabled ? AutomationMethodBadUsb : AutomationMethodNone; + plugin_state->automation_method = scene_state->badusb_enabled ? AutomationMethodBadUsb : + AutomationMethodNone; #ifdef TOTP_BADBT_TYPE_ENABLED - plugin_state->automation_method |= scene_state->badbt_enabled ? AutomationMethodBadBt : - AutomationMethodNone; + plugin_state->automation_method |= scene_state->badbt_enabled ? AutomationMethodBadBt : + AutomationMethodNone; #endif - if(!totp_config_file_update_user_settings(plugin_state)) { - totp_dialogs_config_updating_error(plugin_state); - return false; - } + if(!totp_config_file_update_user_settings(plugin_state)) { + totp_dialogs_config_updating_error(plugin_state); + return false; + } #ifdef TOTP_BADBT_TYPE_ENABLED - if(!scene_state->badbt_enabled && plugin_state->bt_type_code_worker_context != NULL) { - totp_bt_type_code_worker_free(plugin_state->bt_type_code_worker_context); - plugin_state->bt_type_code_worker_context = NULL; - } + if(!scene_state->badbt_enabled && plugin_state->bt_type_code_worker_context != NULL) { + totp_bt_type_code_worker_free(plugin_state->bt_type_code_worker_context); + plugin_state->bt_type_code_worker_context = NULL; + } #endif - totp_scene_director_activate_scene(plugin_state, TotpSceneTokenMenu); - } - break; - case InputKeyBack: { totp_scene_director_activate_scene(plugin_state, TotpSceneTokenMenu); - break; - } - default: - break; } return true; diff --git a/applications/external/totp/ui/scenes/authenticate/totp_scene_authenticate.c b/applications/external/totp/ui/scenes/authenticate/totp_scene_authenticate.c index 86e1e8e2be..218e5e3975 100644 --- a/applications/external/totp/ui/scenes/authenticate/totp_scene_authenticate.c +++ b/applications/external/totp/ui/scenes/authenticate/totp_scene_authenticate.c @@ -83,38 +83,45 @@ bool totp_scene_authenticate_handle_event( return false; } - if(event->input.type != InputTypePress) { - return true; - } - - SceneState* scene_state = (SceneState*)plugin_state->current_scene_state; - - switch(event->input.key) { - case InputKeyUp: - if(scene_state->code_length < MAX_CODE_LENGTH) { - scene_state->code_input[scene_state->code_length] = PinCodeArrowUp; - scene_state->code_length++; - } - break; - case InputKeyDown: - if(scene_state->code_length < MAX_CODE_LENGTH) { - scene_state->code_input[scene_state->code_length] = PinCodeArrowDown; - scene_state->code_length++; + SceneState* scene_state = plugin_state->current_scene_state; + if(event->input.type == InputTypePress) { + switch(event->input.key) { + case InputKeyUp: + if(scene_state->code_length < MAX_CODE_LENGTH) { + scene_state->code_input[scene_state->code_length] = PinCodeArrowUp; + scene_state->code_length++; + } + break; + case InputKeyDown: + if(scene_state->code_length < MAX_CODE_LENGTH) { + scene_state->code_input[scene_state->code_length] = PinCodeArrowDown; + scene_state->code_length++; + } + break; + case InputKeyRight: + if(scene_state->code_length < MAX_CODE_LENGTH) { + scene_state->code_input[scene_state->code_length] = PinCodeArrowRight; + scene_state->code_length++; + } + break; + case InputKeyLeft: + if(scene_state->code_length < MAX_CODE_LENGTH) { + scene_state->code_input[scene_state->code_length] = PinCodeArrowLeft; + scene_state->code_length++; + } + break; + case InputKeyOk: + break; + case InputKeyBack: + if(scene_state->code_length > 0) { + scene_state->code_input[scene_state->code_length - 1] = 0; + scene_state->code_length--; + } + break; + default: + break; } - break; - case InputKeyRight: - if(scene_state->code_length < MAX_CODE_LENGTH) { - scene_state->code_input[scene_state->code_length] = PinCodeArrowRight; - scene_state->code_length++; - } - break; - case InputKeyLeft: - if(scene_state->code_length < MAX_CODE_LENGTH) { - scene_state->code_input[scene_state->code_length] = PinCodeArrowLeft; - scene_state->code_length++; - } - break; - case InputKeyOk: { + } else if(event->input.type == InputTypeRelease && event->input.key == InputKeyOk) { CryptoSeedIVResult seed_result = totp_crypto_seed_iv( plugin_state, &scene_state->code_input[0], scene_state->code_length); @@ -145,16 +152,6 @@ bool totp_scene_authenticate_handle_event( dialog_message_show(plugin_state->dialogs_app, message); dialog_message_free(message); } - break; - } - case InputKeyBack: - if(scene_state->code_length > 0) { - scene_state->code_input[scene_state->code_length - 1] = 0; - scene_state->code_length--; - } - break; - default: - break; } return true; diff --git a/applications/external/totp/ui/scenes/generate_token/totp_scene_generate_token.c b/applications/external/totp/ui/scenes/generate_token/totp_scene_generate_token.c index b111242dce..9b7b282d6f 100644 --- a/applications/external/totp/ui/scenes/generate_token/totp_scene_generate_token.c +++ b/applications/external/totp/ui/scenes/generate_token/totp_scene_generate_token.c @@ -16,7 +16,7 @@ #ifdef TOTP_BADBT_TYPE_ENABLED #include "../../../workers/bt_type_code/bt_type_code.h" #endif -#include "../../fonts/mode-nine/mode_nine.h" +#include "../../fonts/active_font.h" #define PROGRESS_BAR_MARGIN (3) #define PROGRESS_BAR_HEIGHT (4) @@ -142,19 +142,19 @@ static void draw_totp_code(Canvas* const canvas, const PluginState* const plugin totp_config_get_token_iterator_context(plugin_state); uint8_t code_length = totp_token_info_iterator_get_current_token(iterator_context)->digits; uint8_t offset_x = scene_state->ui_precalculated_dimensions.code_offset_x; - uint8_t char_width = modeNine_15ptFontInfo.charInfo[0].width; + uint8_t char_width = TOTP_CODE_FONT_INFO.charInfo[0].width; uint8_t offset_x_inc = scene_state->ui_precalculated_dimensions.code_offset_x_inc; for(uint8_t i = 0; i < code_length; i++) { char ch = scene_state->last_code[i]; - if(ch >= modeNine_15ptFontInfo.startChar && ch <= modeNine_15ptFontInfo.endChar) { - uint8_t char_index = ch - modeNine_15ptFontInfo.startChar; + if(ch >= TOTP_CODE_FONT_INFO.startChar && ch <= TOTP_CODE_FONT_INFO.endChar) { + uint8_t char_index = ch - TOTP_CODE_FONT_INFO.startChar; canvas_draw_xbm( canvas, offset_x, scene_state->ui_precalculated_dimensions.code_offset_y, char_width, - modeNine_15ptFontInfo.height, - &modeNine_15ptFontInfo.data[modeNine_15ptFontInfo.charInfo[char_index].offset]); + TOTP_CODE_FONT_INFO.height, + &TOTP_CODE_FONT_INFO.data[TOTP_CODE_FONT_INFO.charInfo[char_index].offset]); } offset_x += offset_x_inc; @@ -172,15 +172,15 @@ static void on_new_token_code_generated(bool time_left, void* context) { SceneState* scene_state = plugin_state->current_scene_state; const TokenInfo* current_token = totp_token_info_iterator_get_current_token(iterator_context); - uint8_t char_width = modeNine_15ptFontInfo.charInfo[0].width; + uint8_t char_width = TOTP_CODE_FONT_INFO.charInfo[0].width; scene_state->ui_precalculated_dimensions.code_total_length = - current_token->digits * (char_width + modeNine_15ptFontInfo.spacePixels); + current_token->digits * (char_width + TOTP_CODE_FONT_INFO.spacePixels); scene_state->ui_precalculated_dimensions.code_offset_x = (SCREEN_WIDTH - scene_state->ui_precalculated_dimensions.code_total_length) >> 1; scene_state->ui_precalculated_dimensions.code_offset_x_inc = - char_width + modeNine_15ptFontInfo.spacePixels; + char_width + TOTP_CODE_FONT_INFO.spacePixels; scene_state->ui_precalculated_dimensions.code_offset_y = - SCREEN_HEIGHT_CENTER - (modeNine_15ptFontInfo.height >> 1); + SCREEN_HEIGHT_CENTER - (TOTP_CODE_FONT_INFO.height >> 1); if(time_left) { notification_message( @@ -381,54 +381,51 @@ bool totp_scene_generate_token_handle_event( return true; } #endif - } - - if(event->input.type != InputTypePress && event->input.type != InputTypeRepeat) { - return true; - } - - switch(event->input.key) { - case InputKeyUp: - break; - case InputKeyDown: - break; - case InputKeyRight: { - const TokenInfoIteratorContext* iterator_context = - totp_config_get_token_iterator_context(plugin_state); - size_t current_token_index = - totp_token_info_iterator_get_current_token_index(iterator_context); - totp_roll_value_size_t( - ¤t_token_index, - 1, - 0, - totp_token_info_iterator_get_total_count(iterator_context) - 1, - RollOverflowBehaviorRoll); - - update_totp_params(plugin_state, current_token_index); - break; - } - case InputKeyLeft: { - const TokenInfoIteratorContext* iterator_context = - totp_config_get_token_iterator_context(plugin_state); - size_t current_token_index = - totp_token_info_iterator_get_current_token_index(iterator_context); - totp_roll_value_size_t( - ¤t_token_index, - -1, - 0, - totp_token_info_iterator_get_total_count(iterator_context) - 1, - RollOverflowBehaviorRoll); - - update_totp_params(plugin_state, current_token_index); - break; - } - case InputKeyOk: + } else if(event->input.type == InputTypePress || event->input.type == InputTypeRepeat) { + switch(event->input.key) { + case InputKeyUp: + break; + case InputKeyDown: + break; + case InputKeyRight: { + const TokenInfoIteratorContext* iterator_context = + totp_config_get_token_iterator_context(plugin_state); + size_t current_token_index = + totp_token_info_iterator_get_current_token_index(iterator_context); + totp_roll_value_size_t( + ¤t_token_index, + 1, + 0, + totp_token_info_iterator_get_total_count(iterator_context) - 1, + RollOverflowBehaviorRoll); + + update_totp_params(plugin_state, current_token_index); + break; + } + case InputKeyLeft: { + const TokenInfoIteratorContext* iterator_context = + totp_config_get_token_iterator_context(plugin_state); + size_t current_token_index = + totp_token_info_iterator_get_current_token_index(iterator_context); + totp_roll_value_size_t( + ¤t_token_index, + -1, + 0, + totp_token_info_iterator_get_total_count(iterator_context) - 1, + RollOverflowBehaviorRoll); + + update_totp_params(plugin_state, current_token_index); + break; + } + case InputKeyOk: + break; + case InputKeyBack: + break; + default: + break; + } + } else if(event->input.type == InputTypeRelease && event->input.key == InputKeyOk) { totp_scene_director_activate_scene(plugin_state, TotpSceneTokenMenu); - break; - case InputKeyBack: - break; - default: - break; } return true; diff --git a/applications/external/totp/ui/scenes/token_menu/totp_scene_token_menu.c b/applications/external/totp/ui/scenes/token_menu/totp_scene_token_menu.c index a8c8de28a3..1340b5a8e8 100644 --- a/applications/external/totp/ui/scenes/token_menu/totp_scene_token_menu.c +++ b/applications/external/totp/ui/scenes/token_menu/totp_scene_token_menu.c @@ -82,38 +82,52 @@ bool totp_scene_token_menu_handle_event(const PluginEvent* const event, PluginSt } SceneState* scene_state = (SceneState*)plugin_state->current_scene_state; - if(event->input.type != InputTypePress) { - return true; - } - - switch(event->input.key) { - case InputKeyUp: { - const TokenInfoIteratorContext* iterator_context = - totp_config_get_token_iterator_context(plugin_state); - totp_roll_value_uint8_t( - &scene_state->selected_control, -1, AddNewToken, AppSettings, RollOverflowBehaviorRoll); - if(scene_state->selected_control == DeleteToken && - totp_token_info_iterator_get_total_count(iterator_context) == 0) { - scene_state->selected_control--; + if(event->input.type == InputTypePress) { + switch(event->input.key) { + case InputKeyUp: { + const TokenInfoIteratorContext* iterator_context = + totp_config_get_token_iterator_context(plugin_state); + totp_roll_value_uint8_t( + &scene_state->selected_control, + -1, + AddNewToken, + AppSettings, + RollOverflowBehaviorRoll); + if(scene_state->selected_control == DeleteToken && + totp_token_info_iterator_get_total_count(iterator_context) == 0) { + scene_state->selected_control--; + } + break; } - break; - } - case InputKeyDown: { - const TokenInfoIteratorContext* iterator_context = - totp_config_get_token_iterator_context(plugin_state); - totp_roll_value_uint8_t( - &scene_state->selected_control, 1, AddNewToken, AppSettings, RollOverflowBehaviorRoll); - if(scene_state->selected_control == DeleteToken && - totp_token_info_iterator_get_total_count(iterator_context) == 0) { - scene_state->selected_control++; + case InputKeyDown: { + const TokenInfoIteratorContext* iterator_context = + totp_config_get_token_iterator_context(plugin_state); + totp_roll_value_uint8_t( + &scene_state->selected_control, + 1, + AddNewToken, + AppSettings, + RollOverflowBehaviorRoll); + if(scene_state->selected_control == DeleteToken && + totp_token_info_iterator_get_total_count(iterator_context) == 0) { + scene_state->selected_control++; + } + break; } - break; - } - case InputKeyRight: - break; - case InputKeyLeft: - break; - case InputKeyOk: + case InputKeyRight: + break; + case InputKeyLeft: + break; + case InputKeyOk: + break; + case InputKeyBack: { + totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken); + break; + } + default: + break; + } + } else if(event->input.type == InputTypeRelease && event->input.key == InputKeyOk) { switch(scene_state->selected_control) { case AddNewToken: { totp_scene_director_activate_scene(plugin_state, TotpSceneAddNewToken); @@ -153,13 +167,6 @@ bool totp_scene_token_menu_handle_event(const PluginEvent* const event, PluginSt default: break; } - break; - case InputKeyBack: { - totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken); - break; - } - default: - break; } return true; diff --git a/applications/external/totp/workers/generate_totp_code/generate_totp_code.c b/applications/external/totp/workers/generate_totp_code/generate_totp_code.c index 7e9356c45b..6dbe329fd6 100644 --- a/applications/external/totp/workers/generate_totp_code/generate_totp_code.c +++ b/applications/external/totp/workers/generate_totp_code/generate_totp_code.c @@ -25,18 +25,21 @@ static const char* STEAM_ALGO_ALPHABET = "23456789BCDFGHJKMNPQRTVWXY"; static void int_token_to_str(uint64_t i_token_code, char* str, TokenDigitsCount len, TokenHashAlgo algo) { - str[len] = '\0'; + char* last_char = str + len; + *last_char = '\0'; if(i_token_code == OTP_ERROR) { - memset(&str[0], '-', len); + memset(str, '-', len); } else { if(algo == STEAM) { - for(uint8_t i = 0; i < len; i++) { - str[i] = STEAM_ALGO_ALPHABET[i_token_code % 26]; + char* s = str; + for(uint8_t i = 0; i < len; i++, s++) { + *s = STEAM_ALGO_ALPHABET[i_token_code % 26]; i_token_code = i_token_code / 26; } } else { - for(int8_t i = len - 1; i >= 0; i--) { - str[i] = CONVERT_DIGIT_TO_CHAR(i_token_code % 10); + char* s = --last_char; + for(int8_t i = len - 1; i >= 0; i--, s--) { + *s = CONVERT_DIGIT_TO_CHAR(i_token_code % 10); i_token_code = i_token_code / 10; } } diff --git a/applications/external/totp/workers/type_code_common.c b/applications/external/totp/workers/type_code_common.c index bf5818ab27..bc42fadaaf 100644 --- a/applications/external/totp/workers/type_code_common.c +++ b/applications/external/totp/workers/type_code_common.c @@ -47,11 +47,12 @@ void totp_type_code_worker_execute_automation( TokenAutomationFeature features) { furi_delay_ms(500); uint8_t i = 0; + char cb_char; - while(i < code_buffer_size && code_buffer[i] != 0) { - uint8_t char_index = CONVERT_CHAR_TO_DIGIT(code_buffer[i]); + while(i < code_buffer_size && (cb_char = code_buffer[i]) != 0) { + uint8_t char_index = CONVERT_CHAR_TO_DIGIT(cb_char); if(char_index > 9) { - char_index = code_buffer[i] - 0x41 + 10; + char_index = cb_char - 0x41 + 10; } if(char_index > 35) break; From b9397693a2d7d781126f77535938ad6148193f5f Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 26 May 2023 15:09:10 +0300 Subject: [PATCH 70/92] Setting to change fonts in TOTP opensource != selling plugin builds / do you agree? If you don't agree - and you think I did a bad thing here by allowing users to select fonts without payment, let me know Why I did that? - cuz I'm not making private "donation only" builds myself, while having no main job, and living only on donations, so I don't like stuff like that in opensource projects You should support author if you like this plugin here: https://github.com/akopachov/flipper-zero_authenticator --- applications/external/totp/features_config.h | 4 +- .../external/totp/services/config/config.c | 38 ++++++++++ .../external/totp/services/config/config.h | 7 ++ .../external/totp/services/config/constants.h | 1 + .../config/migrations/common_migration.c | 9 +++ applications/external/totp/totp_app.c | 1 + .../external/totp/types/plugin_state.h | 5 ++ .../external/totp/ui/fonts/active_font.h | 15 ---- .../scenes/app_settings/totp_app_settings.c | 37 ++++++++-- .../totp_scene_generate_token.c | 73 ++++++++++++++++--- .../totp/workers/bt_type_code/bt_type_code.c | 12 +-- 11 files changed, 163 insertions(+), 39 deletions(-) diff --git a/applications/external/totp/features_config.h b/applications/external/totp/features_config.h index 683eff2fce..c789af27b5 100644 --- a/applications/external/totp/features_config.h +++ b/applications/external/totp/features_config.h @@ -7,8 +7,8 @@ // List of compatible firmwares #define TOTP_FIRMWARE_OFFICIAL_STABLE 1 #define TOTP_FIRMWARE_OFFICIAL_DEV 2 -#define TOTP_FIRMWARE_XTREME 3 +#define TOTP_FIRMWARE_UL_XFW 3 // XFW and UL now has same bluetooth mac/advname changing API // End of list // Target firmware to build for -#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME \ No newline at end of file +#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_UL_XFW diff --git a/applications/external/totp/services/config/config.c b/applications/external/totp/services/config/config.c index f97bc6b264..7b935e1eab 100644 --- a/applications/external/totp/services/config/config.c +++ b/applications/external/totp/services/config/config.c @@ -177,6 +177,10 @@ static bool totp_open_config_file(Storage* storage, FlipperFormat** file) { flipper_format_write_uint32( fff_data_file, TOTP_CONFIG_KEY_AUTOMATION_METHOD, &tmp_uint32, 1); + // Default Font = 0 + tmp_uint32 = 0; + flipper_format_write_uint32(fff_data_file, TOTP_CONFIG_KEY_SELECTED_FONT, &tmp_uint32, 1); + if(!flipper_format_rewind(fff_data_file)) { totp_close_config_file(fff_data_file); FURI_LOG_E(LOGGING_TAG, "Rewind error"); @@ -259,6 +263,24 @@ bool totp_config_file_update_automation_method(const PluginState* plugin_state) return update_result; } +bool totp_config_file_update_selected_font(const PluginState* plugin_state) { + FlipperFormat* file = plugin_state->config_file_context->config_file; + flipper_format_rewind(file); + bool update_result = false; + + do { + uint32_t tmp_uint32 = plugin_state->selected_font; + if(!flipper_format_insert_or_update_uint32( + file, TOTP_CONFIG_KEY_SELECTED_FONT, &tmp_uint32, 1)) { + break; + } + + update_result = true; + } while(false); + + return update_result; +} + bool totp_config_file_update_user_settings(const PluginState* plugin_state) { FlipperFormat* file = plugin_state->config_file_context->config_file; flipper_format_rewind(file); @@ -280,6 +302,12 @@ bool totp_config_file_update_user_settings(const PluginState* plugin_state) { break; } + tmp_uint32 = plugin_state->selected_font; + if(!flipper_format_insert_or_update_uint32( + file, TOTP_CONFIG_KEY_SELECTED_FONT, &tmp_uint32, 1)) { + break; + } + update_result = true; } while(false); @@ -428,6 +456,16 @@ bool totp_config_file_load(PluginState* const plugin_state) { plugin_state->automation_method = tmp_uint32; + // Load selected font + flipper_format_rewind(fff_data_file); + + if(!flipper_format_read_uint32( + fff_data_file, TOTP_CONFIG_KEY_SELECTED_FONT, &tmp_uint32, 1)) { + tmp_uint32 = 0; + } + + plugin_state->selected_font = tmp_uint32; + plugin_state->config_file_context = malloc(sizeof(ConfigFileContext)); furi_check(plugin_state->config_file_context != NULL); plugin_state->config_file_context->storage = storage; diff --git a/applications/external/totp/services/config/config.h b/applications/external/totp/services/config/config.h index d2fe957c66..cc278ab5a3 100644 --- a/applications/external/totp/services/config/config.h +++ b/applications/external/totp/services/config/config.h @@ -44,6 +44,13 @@ bool totp_config_file_update_notification_method(const PluginState* plugin_state */ bool totp_config_file_update_automation_method(const PluginState* plugin_state); +/** + * @brief Updates selected font in an application config file + * @param plugin_state application state + * @return Config file update result + */ +bool totp_config_file_update_selected_font(const PluginState* plugin_state); + /** * @brief Updates application user settings * @param plugin_state application state diff --git a/applications/external/totp/services/config/constants.h b/applications/external/totp/services/config/constants.h index 3a33c80b39..27a4f56c4e 100644 --- a/applications/external/totp/services/config/constants.h +++ b/applications/external/totp/services/config/constants.h @@ -18,3 +18,4 @@ #define TOTP_CONFIG_KEY_PINSET "PinIsSet" #define TOTP_CONFIG_KEY_NOTIFICATION_METHOD "NotificationMethod" #define TOTP_CONFIG_KEY_AUTOMATION_METHOD "AutomationMethod" +#define TOTP_CONFIG_KEY_SELECTED_FONT "SelectedFont" diff --git a/applications/external/totp/services/config/migrations/common_migration.c b/applications/external/totp/services/config/migrations/common_migration.c index 07026fb1f3..9cee422a57 100644 --- a/applications/external/totp/services/config/migrations/common_migration.c +++ b/applications/external/totp/services/config/migrations/common_migration.c @@ -58,6 +58,15 @@ bool totp_config_migrate_to_latest( flipper_format_rewind(fff_backup_data_file); + // Font + + if(flipper_format_read_string( + fff_backup_data_file, TOTP_CONFIG_KEY_SELECTED_FONT, temp_str)) { + flipper_format_write_string(fff_data_file, TOTP_CONFIG_KEY_SELECTED_FONT, temp_str); + } + + flipper_format_rewind(fff_backup_data_file); + while(true) { if(!flipper_format_read_string( fff_backup_data_file, TOTP_CONFIG_KEY_TOKEN_NAME, temp_str)) { diff --git a/applications/external/totp/totp_app.c b/applications/external/totp/totp_app.c index f620a3b48c..8b0a8c1fa4 100644 --- a/applications/external/totp/totp_app.c +++ b/applications/external/totp/totp_app.c @@ -107,6 +107,7 @@ static bool totp_activate_initial_scene(PluginState* const plugin_state) { } static bool totp_plugin_state_init(PluginState* const plugin_state) { + plugin_state->selected_font = 0; plugin_state->gui = furi_record_open(RECORD_GUI); plugin_state->notification_app = furi_record_open(RECORD_NOTIFICATION); plugin_state->dialogs_app = furi_record_open(RECORD_DIALOGS); diff --git a/applications/external/totp/types/plugin_state.h b/applications/external/totp/types/plugin_state.h index c20594f373..97d126330b 100644 --- a/applications/external/totp/types/plugin_state.h +++ b/applications/external/totp/types/plugin_state.h @@ -80,6 +80,11 @@ typedef struct { */ NotificationMethod notification_method; + /** + * @brief Numbers Font + */ + uint8_t selected_font; + /** * @brief Main rendering loop mutex */ diff --git a/applications/external/totp/ui/fonts/active_font.h b/applications/external/totp/ui/fonts/active_font.h index 58c1e2d176..054fa4a558 100644 --- a/applications/external/totp/ui/fonts/active_font.h +++ b/applications/external/totp/ui/fonts/active_font.h @@ -3,25 +3,10 @@ #include "../../features_config.h" #include "font_info.h" -#if TOTP_FONT == TOTP_FONT_MODENINE #include "mode_nine/mode_nine.h" -#define TOTP_CODE_FONT_INFO modeNine_15ptFontInfo -#elif TOTP_FONT == TOTP_FONT_REDHATMONO #include "redhat_mono/redhat_mono.h" -#define TOTP_CODE_FONT_INFO redHatMono_16ptFontInfo -#elif TOTP_FONT == TOTP_FONT_BEDSTEAD #include "bedstead/bedstead.h" -#define TOTP_CODE_FONT_INFO bedstead_17ptFontInfo -#elif TOTP_FONT == TOTP_FONT_ZECTOR #include "zector/zector.h" -#define TOTP_CODE_FONT_INFO zector_18ptFontInfo -#elif TOTP_FONT == TOTP_FONT_712SERIF #include "712serif/712serif.h" -#define TOTP_CODE_FONT_INFO _712Serif_24ptFontInfo -#elif TOTP_FONT == TOTP_FONT_GRAPH35PIX #include "graph35pix/graph35pix.h" -#define TOTP_CODE_FONT_INFO graph35pix_12ptFontInfo -#elif TOTP_FONT == TOTP_FONT_KARMAFUTURE #include "karma_future/karma_future.h" -#define TOTP_CODE_FONT_INFO karmaFuture_14ptFontInfo -#endif \ No newline at end of file diff --git a/applications/external/totp/ui/scenes/app_settings/totp_app_settings.c b/applications/external/totp/ui/scenes/app_settings/totp_app_settings.c index 54659946d2..0bdc7aee36 100644 --- a/applications/external/totp/ui/scenes/app_settings/totp_app_settings.c +++ b/applications/external/totp/ui/scenes/app_settings/totp_app_settings.c @@ -22,6 +22,7 @@ typedef enum { MinutesInput, Sound, Vibro, + FontSelector, BadUsb, #ifdef TOTP_BADBT_TYPE_ENABLED BadBt, @@ -34,6 +35,7 @@ typedef struct { uint8_t tz_offset_minutes; bool notification_sound; bool notification_vibro; + uint8_t selected_font; bool badusb_enabled; #ifdef TOTP_BADBT_TYPE_ENABLED bool badbt_enabled; @@ -54,6 +56,7 @@ void totp_scene_app_settings_activate(PluginState* plugin_state) { scene_state->notification_sound = plugin_state->notification_method & NotificationMethodSound; scene_state->notification_vibro = plugin_state->notification_method & NotificationMethodVibro; scene_state->badusb_enabled = plugin_state->automation_method & AutomationMethodBadUsb; + scene_state->selected_font = plugin_state->selected_font; #ifdef TOTP_BADBT_TYPE_ENABLED scene_state->badbt_enabled = plugin_state->automation_method & AutomationMethodBadBt; #endif @@ -111,27 +114,38 @@ void totp_scene_app_settings_render(Canvas* const canvas, const PluginState* plu canvas_set_font(canvas, FontPrimary); canvas_draw_str_aligned( - canvas, 0, 64 - scene_state->y_offset, AlignLeft, AlignTop, "Notifications"); + canvas, 0, 64 - scene_state->y_offset, AlignLeft, AlignTop, "Notifications / UI"); canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 0, 81 - scene_state->y_offset, AlignLeft, AlignTop, "Sound:"); + canvas_draw_str_aligned(canvas, 0, 78 - scene_state->y_offset, AlignLeft, AlignTop, "Sound:"); ui_control_select_render( canvas, 36, - 74 - scene_state->y_offset, + 71 - scene_state->y_offset, SCREEN_WIDTH - 36, YES_NO_LIST[scene_state->notification_sound], scene_state->selected_control == Sound); - canvas_draw_str_aligned(canvas, 0, 99 - scene_state->y_offset, AlignLeft, AlignTop, "Vibro:"); + canvas_draw_str_aligned(canvas, 0, 94 - scene_state->y_offset, AlignLeft, AlignTop, "Vibro:"); ui_control_select_render( canvas, 36, - 92 - scene_state->y_offset, + 87 - scene_state->y_offset, SCREEN_WIDTH - 36, YES_NO_LIST[scene_state->notification_vibro], scene_state->selected_control == Vibro); + two_digit_to_str(scene_state->selected_font, &tmp_str[0]); + canvas_draw_str_aligned( + canvas, 0, 110 - scene_state->y_offset, AlignLeft, AlignTop, "UI Font:"); + ui_control_select_render( + canvas, + 36, + 103 - scene_state->y_offset, + SCREEN_WIDTH - 36, + &tmp_str[0], + scene_state->selected_control == FontSelector); + canvas_draw_icon( canvas, SCREEN_WIDTH_CENTER - 5, 123 - scene_state->y_offset, &I_totp_arrow_bottom_10x5); @@ -192,7 +206,7 @@ bool totp_scene_app_settings_handle_event( HoursInput, ConfirmButton, RollOverflowBehaviorStop); - if(scene_state->selected_control > Vibro) { + if(scene_state->selected_control > FontSelector) { scene_state->y_offset = 128; } else if(scene_state->selected_control > MinutesInput) { scene_state->y_offset = 64; @@ -207,7 +221,7 @@ bool totp_scene_app_settings_handle_event( HoursInput, ConfirmButton, RollOverflowBehaviorStop); - if(scene_state->selected_control > Vibro) { + if(scene_state->selected_control > FontSelector) { scene_state->y_offset = 128; } else if(scene_state->selected_control > MinutesInput) { scene_state->y_offset = 64; @@ -234,6 +248,10 @@ bool totp_scene_app_settings_handle_event( scene_state->badbt_enabled = !scene_state->badbt_enabled; } #endif + else if(scene_state->selected_control == FontSelector) { + totp_roll_value_uint8_t( + &scene_state->selected_font, 1, 0, 6, RollOverflowBehaviorStop); + } break; case InputKeyLeft: if(scene_state->selected_control == HoursInput) { @@ -254,6 +272,10 @@ bool totp_scene_app_settings_handle_event( scene_state->badbt_enabled = !scene_state->badbt_enabled; } #endif + else if(scene_state->selected_control == FontSelector) { + totp_roll_value_uint8_t( + &scene_state->selected_font, -1, 0, 6, RollOverflowBehaviorStop); + } break; case InputKeyOk: break; @@ -280,6 +302,7 @@ bool totp_scene_app_settings_handle_event( plugin_state->automation_method |= scene_state->badbt_enabled ? AutomationMethodBadBt : AutomationMethodNone; #endif + plugin_state->selected_font = scene_state->selected_font; if(!totp_config_file_update_user_settings(plugin_state)) { totp_dialogs_config_updating_error(plugin_state); diff --git a/applications/external/totp/ui/scenes/generate_token/totp_scene_generate_token.c b/applications/external/totp/ui/scenes/generate_token/totp_scene_generate_token.c index 9b7b282d6f..e55f34ea27 100644 --- a/applications/external/totp/ui/scenes/generate_token/totp_scene_generate_token.c +++ b/applications/external/totp/ui/scenes/generate_token/totp_scene_generate_token.c @@ -142,19 +142,46 @@ static void draw_totp_code(Canvas* const canvas, const PluginState* const plugin totp_config_get_token_iterator_context(plugin_state); uint8_t code_length = totp_token_info_iterator_get_current_token(iterator_context)->digits; uint8_t offset_x = scene_state->ui_precalculated_dimensions.code_offset_x; - uint8_t char_width = TOTP_CODE_FONT_INFO.charInfo[0].width; + const FONT_INFO* current_font; + switch(plugin_state->selected_font) { + case 0: + current_font = &modeNine_15ptFontInfo; + break; + case 1: + current_font = &redHatMono_16ptFontInfo; + break; + case 2: + current_font = &bedstead_17ptFontInfo; + break; + case 3: + current_font = &zector_18ptFontInfo; + break; + case 4: + current_font = &_712Serif_24ptFontInfo; + break; + case 5: + current_font = &graph35pix_12ptFontInfo; + break; + case 6: + current_font = &karmaFuture_14ptFontInfo; + break; + default: + current_font = &modeNine_15ptFontInfo; + break; + } + uint8_t char_width = current_font->charInfo[0].width; uint8_t offset_x_inc = scene_state->ui_precalculated_dimensions.code_offset_x_inc; for(uint8_t i = 0; i < code_length; i++) { char ch = scene_state->last_code[i]; - if(ch >= TOTP_CODE_FONT_INFO.startChar && ch <= TOTP_CODE_FONT_INFO.endChar) { - uint8_t char_index = ch - TOTP_CODE_FONT_INFO.startChar; + if(ch >= current_font->startChar && ch <= current_font->endChar) { + uint8_t char_index = ch - current_font->startChar; canvas_draw_xbm( canvas, offset_x, scene_state->ui_precalculated_dimensions.code_offset_y, char_width, - TOTP_CODE_FONT_INFO.height, - &TOTP_CODE_FONT_INFO.data[TOTP_CODE_FONT_INFO.charInfo[char_index].offset]); + current_font->height, + ¤t_font->data[current_font->charInfo[char_index].offset]); } offset_x += offset_x_inc; @@ -172,15 +199,43 @@ static void on_new_token_code_generated(bool time_left, void* context) { SceneState* scene_state = plugin_state->current_scene_state; const TokenInfo* current_token = totp_token_info_iterator_get_current_token(iterator_context); - uint8_t char_width = TOTP_CODE_FONT_INFO.charInfo[0].width; + const FONT_INFO* current_font; + switch(plugin_state->selected_font) { + case 0: + current_font = &modeNine_15ptFontInfo; + break; + case 1: + current_font = &redHatMono_16ptFontInfo; + break; + case 2: + current_font = &bedstead_17ptFontInfo; + break; + case 3: + current_font = &zector_18ptFontInfo; + break; + case 4: + current_font = &_712Serif_24ptFontInfo; + break; + case 5: + current_font = &graph35pix_12ptFontInfo; + break; + case 6: + current_font = &karmaFuture_14ptFontInfo; + break; + default: + current_font = &modeNine_15ptFontInfo; + break; + } + + uint8_t char_width = current_font->charInfo[0].width; scene_state->ui_precalculated_dimensions.code_total_length = - current_token->digits * (char_width + TOTP_CODE_FONT_INFO.spacePixels); + current_token->digits * (char_width + current_font->spacePixels); scene_state->ui_precalculated_dimensions.code_offset_x = (SCREEN_WIDTH - scene_state->ui_precalculated_dimensions.code_total_length) >> 1; scene_state->ui_precalculated_dimensions.code_offset_x_inc = - char_width + TOTP_CODE_FONT_INFO.spacePixels; + char_width + current_font->spacePixels; scene_state->ui_precalculated_dimensions.code_offset_y = - SCREEN_HEIGHT_CENTER - (TOTP_CODE_FONT_INFO.height >> 1); + SCREEN_HEIGHT_CENTER - (current_font->height >> 1); if(time_left) { notification_message( diff --git a/applications/external/totp/workers/bt_type_code/bt_type_code.c b/applications/external/totp/workers/bt_type_code/bt_type_code.c index bf55dba6a8..8024dba78b 100644 --- a/applications/external/totp/workers/bt_type_code/bt_type_code.c +++ b/applications/external/totp/workers/bt_type_code/bt_type_code.c @@ -13,7 +13,7 @@ #include "../type_code_common.h" #include "../../features_config.h" -#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME +#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW #define TOTP_BT_WORKER_BT_ADV_NAME_MAX_LEN FURI_HAL_BT_ADV_NAME_LENGTH #define TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN GAP_MAC_ADDR_SIZE #endif @@ -29,7 +29,7 @@ struct TotpBtTypeCodeWorkerContext { Bt* bt; bool is_advertising; bool is_connected; -#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME +#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW char previous_bt_name[TOTP_BT_WORKER_BT_ADV_NAME_MAX_LEN]; uint8_t previous_bt_mac[TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN]; #endif @@ -39,7 +39,7 @@ static inline bool totp_type_code_worker_stop_requested() { return furi_thread_flags_get() & TotpBtTypeCodeWorkerEventStop; } -#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME +#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW static void totp_type_code_worker_bt_set_app_mac(uint8_t* mac) { uint8_t max_i; size_t uid_size = furi_hal_version_uid_size(); @@ -161,7 +161,7 @@ TotpBtTypeCodeWorkerContext* totp_bt_type_code_worker_init() { furi_delay_ms(200); bt_keys_storage_set_storage_path(context->bt, HID_BT_KEYS_STORAGE_PATH); -#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME +#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW memcpy( &context->previous_bt_name[0], furi_hal_bt_get_profile_adv_name(FuriHalBtProfileHidKeyboard), @@ -184,7 +184,7 @@ TotpBtTypeCodeWorkerContext* totp_bt_type_code_worker_init() { furi_hal_bt_start_advertising(); -#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME +#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW bt_enable_peer_key_update(context->bt); #endif @@ -211,7 +211,7 @@ void totp_bt_type_code_worker_free(TotpBtTypeCodeWorkerContext* context) { furi_delay_ms(200); bt_keys_storage_set_default_path(context->bt); -#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME +#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW furi_hal_bt_set_profile_adv_name(FuriHalBtProfileHidKeyboard, context->previous_bt_name); furi_hal_bt_set_profile_mac_addr(FuriHalBtProfileHidKeyboard, context->previous_bt_mac); #endif From 5a7cd203cdfeef9dd26fe14e89990ab0ef482a9c Mon Sep 17 00:00:00 2001 From: Yukai Li Date: Fri, 26 May 2023 06:50:59 -0600 Subject: [PATCH 71/92] nfc: Fix MFUL tearing flags read (#2669) Co-authored-by: gornekich --- lib/nfc/protocols/mifare_ultralight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nfc/protocols/mifare_ultralight.c b/lib/nfc/protocols/mifare_ultralight.c index 0e28c0074f..6960bd2a18 100644 --- a/lib/nfc/protocols/mifare_ultralight.c +++ b/lib/nfc/protocols/mifare_ultralight.c @@ -702,7 +702,7 @@ bool mf_ultralight_read_tearing_flags(FuriHalNfcTxRxContext* tx_rx, MfUltralight FURI_LOG_D(TAG, "Reading tearing flags"); for(size_t i = 0; i < 3; i++) { tx_rx->tx_data[0] = MF_UL_CHECK_TEARING; - tx_rx->rx_data[1] = i; + tx_rx->tx_data[1] = i; tx_rx->tx_bits = 16; tx_rx->tx_rx_type = FuriHalNfcTxRxTypeDefault; if(!furi_hal_nfc_tx_rx(tx_rx, 50)) { From 4f054ed53595d901b5fa755eb3402ae1e0231fd1 Mon Sep 17 00:00:00 2001 From: hedger Date: Fri, 26 May 2023 16:57:24 +0400 Subject: [PATCH 72/92] api: added toolbox/api_lock.h (#2702) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- firmware/targets/f18/api_symbols.csv | 3 ++- firmware/targets/f7/api_symbols.csv | 1 + lib/toolbox/SConscript | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/firmware/targets/f18/api_symbols.csv b/firmware/targets/f18/api_symbols.csv index b7abdfc050..68248a6d2b 100644 --- a/firmware/targets/f18/api_symbols.csv +++ b/firmware/targets/f18/api_symbols.csv @@ -129,6 +129,7 @@ Header,+,lib/one_wire/maxim_crc.h,, Header,+,lib/one_wire/one_wire_host.h,, Header,+,lib/one_wire/one_wire_slave.h,, Header,+,lib/print/wrappers.h,, +Header,+,lib/pulse_reader/pulse_reader.h,, Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_adc.h,, Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_bus.h,, Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_comp.h,, @@ -156,7 +157,7 @@ Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_tim.h,, Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_usart.h,, Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_utils.h,, Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_wwdg.h,, -Header,+,lib/pulse_reader/pulse_reader.h,, +Header,+,lib/toolbox/api_lock.h,, Header,+,lib/toolbox/args.h,, Header,+,lib/toolbox/crc32_calc.h,, Header,+,lib/toolbox/dir_walk.h,, diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 15c19091e9..aebfc9072b 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -190,6 +190,7 @@ Header,+,lib/subghz/subghz_setting.h,, Header,+,lib/subghz/subghz_tx_rx_worker.h,, Header,+,lib/subghz/subghz_worker.h,, Header,+,lib/subghz/transmitter.h,, +Header,+,lib/toolbox/api_lock.h,, Header,+,lib/toolbox/args.h,, Header,+,lib/toolbox/crc32_calc.h,, Header,+,lib/toolbox/dir_walk.h,, diff --git a/lib/toolbox/SConscript b/lib/toolbox/SConscript index 4e158e30ea..6084969c4c 100644 --- a/lib/toolbox/SConscript +++ b/lib/toolbox/SConscript @@ -8,6 +8,7 @@ env.Append( "#/lib/toolbox", ], SDK_HEADERS=[ + File("api_lock.h"), File("manchester_decoder.h"), File("manchester_encoder.h"), File("path.h"), From cce0485e75f39c3a7ef504054f15b819deeb7e0a Mon Sep 17 00:00:00 2001 From: technobulb <84107091+technobulb@users.noreply.github.com> Date: Fri, 26 May 2023 09:12:21 -0400 Subject: [PATCH 73/92] Update ac.ir (#2701) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- assets/resources/infrared/assets/ac.ir | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/assets/resources/infrared/assets/ac.ir b/assets/resources/infrared/assets/ac.ir index cfa62f6a24..e06c95f715 100644 --- a/assets/resources/infrared/assets/ac.ir +++ b/assets/resources/infrared/assets/ac.ir @@ -408,3 +408,29 @@ type: raw frequency: 38000 duty_cycle: 0.330000 data: 3108 3851 2062 1793 2006 1821 1103 839 2031 859 1085 829 1081 833 1079 836 1045 1911 1973 897 1015 898 1016 899 1041 871 1016 899 1014 898 1015 899 1015 899 1014 899 1041 872 1015 899 1041 872 1041 872 1015 899 1015 899 1041 873 1014 899 1041 873 1014 899 1014 1883 1975 900 3045 3886 1997 1856 1945 1857 1012 927 1945 900 1013 901 1012 901 1013 901 1012 1859 1999 901 1012 930 1012 903 1011 903 1010 903 1011 902 1012 960 1011 928 986 932 1010 903 1011 928 1015 928 985 929 985 928 1014 928 985 929 985 929 984 929 985 928 986 1915 1971 928 3017 3915 1942 1885 1943 1885 985 930 1971 929 984 930 983 930 984 930 984 1887 1942 929 983 960 983 931 982 931 983 932 981 958 985 958 956 958 984 959 954 931 983 932 981 959 955 932 982 959 954 960 982 961 983 933 955 988 955 985 929 1943 1915 958 4003 +# +# Model: Danby DAC060EB7WDB +name: Off +type: raw +frequency: 38000 +duty_cycle: 0.330000 +data: 4402 4442 527 1629 529 549 529 1628 530 550 529 548 531 549 530 550 529 1630 528 549 530 549 529 549 530 1630 527 1629 529 1630 528 548 530 550 529 547 531 1628 530 1629 529 1628 530 1628 529 1628 530 1628 530 549 530 1628 530 1628 530 1627 531 1628 530 1627 531 1631 527 1629 529 1628 530 1627 531 1628 530 1628 530 1629 529 1627 531 1627 531 1628 529 1627 531 1627 531 1629 529 1627 530 549 529 549 530 549 530 1628 529 1627 530 5234 4401 4440 530 550 528 1628 529 549 530 1628 529 1629 528 1626 531 1628 529 550 529 1628 530 1627 531 1629 529 549 529 548 530 549 530 1628 529 1628 530 1627 530 547 532 547 532 547 531 548 531 548 530 548 531 1626 531 549 530 547 531 547 531 548 530 548 530 549 530 548 531 546 532 578 500 547 532 548 531 548 531 548 530 548 531 548 530 548 531 547 531 547 532 547 531 1627 531 1627 530 1626 532 547 531 547 532 +# +name: Dh +type: raw +frequency: 38000 +duty_cycle: 0.330000 +data: 4454 4387 586 1573 585 494 584 1571 586 494 584 493 585 524 554 493 531 1626 586 1573 585 494 585 492 586 492 586 494 585 493 585 493 586 1571 586 493 585 1572 531 1627 530 549 584 494 586 1571 587 1572 529 1628 529 1628 530 1627 530 1626 532 1627 531 1626 532 1628 529 1627 531 1626 531 1627 531 1627 587 1569 532 1625 533 1626 532 1626 532 1627 531 1627 530 548 531 1626 532 1627 531 548 531 1627 531 548 531 546 532 547 531 5233 4401 4443 530 548 530 1627 530 547 531 1627 531 1626 531 1626 531 1627 530 549 530 548 530 1627 531 1627 531 1627 530 1627 531 1627 531 1626 531 548 530 1627 530 547 532 547 532 1627 531 1627 532 546 531 547 531 548 530 548 530 548 531 548 531 548 530 548 530 549 530 548 531 548 531 548 530 547 532 549 529 548 530 548 531 547 532 548 530 548 531 1627 530 548 530 548 531 1626 533 546 531 1627 530 1627 532 1626 530 +# +name: Cool_hi +type: raw +frequency: 38000 +duty_cycle: 0.330000 +data: 4492 4354 619 1537 619 459 621 1537 622 455 623 456 623 457 622 456 623 1535 622 1536 622 458 621 456 623 1536 621 1535 623 456 622 456 623 457 621 456 531 1627 621 1536 622 456 622 457 622 455 623 458 621 458 621 1537 621 1536 620 1539 618 1538 531 1628 531 1627 530 1628 530 1628 530 1627 531 1628 530 1628 530 1628 531 1627 530 1629 529 1628 529 1628 530 549 530 1627 531 1628 530 1628 530 1627 586 494 530 1627 530 549 530 5232 4400 4443 586 492 587 1571 587 493 585 1572 530 1628 586 1572 586 1572 586 492 587 493 586 1572 586 1571 586 492 587 493 585 1572 531 1627 585 1573 585 1572 585 492 586 494 585 1572 586 1571 531 1627 531 1628 530 1627 587 491 531 548 587 492 530 548 530 547 532 548 531 547 532 547 531 548 531 547 532 547 531 548 588 491 530 547 589 490 531 547 532 1626 532 548 531 548 531 547 532 547 532 1627 531 548 531 1626 532 +# +name: Cool_lo +type: raw +frequency: 38000 +duty_cycle: 0.330000 +data: 4401 4441 528 1629 529 550 528 1628 529 551 528 550 528 551 527 551 528 1629 529 1629 529 550 529 1630 528 551 528 549 530 550 529 551 528 549 529 550 529 1629 529 1628 530 549 530 1629 529 550 529 1628 529 1629 529 1631 527 1628 530 1628 529 1629 528 1628 530 1629 529 1629 529 1629 529 1629 528 1629 529 1629 529 1630 528 1629 529 1629 529 1628 529 1629 528 551 528 1629 529 550 529 550 530 548 529 1631 527 551 528 1629 529 5235 4402 4439 530 550 528 1629 529 549 530 1628 529 1629 529 1628 530 1629 529 549 530 550 529 1628 530 552 526 1628 529 1628 530 1628 530 1627 531 1628 529 1629 528 551 528 550 529 1628 530 550 528 1628 529 549 529 550 528 550 529 549 530 548 530 551 528 550 528 578 500 550 529 550 529 551 527 549 530 549 529 549 529 550 528 548 530 550 528 549 529 1629 528 550 529 1630 528 1628 530 1628 530 549 530 1628 529 549 529 +# From 5f52382098855e05b4239966cbe274551abdf538 Mon Sep 17 00:00:00 2001 From: Yukai Li Date: Fri, 26 May 2023 07:19:10 -0600 Subject: [PATCH 74/92] nfc: Mifare Ultralight C detection (#2668) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * nfc: Add Mifare Ultralight C detection * nfc: Add display name for MFUL C and hide menu items MFUL C unlock and emulation currently not supported, so hide from menu if current card is MFUL C * nfc: Also check response when probing 3DES auth * nfc: Hide emulate option in saved menu for MFUL if not supported * nfc: Remove unlock options from saved menu if Ultralight C Co-authored-by: gornekich Co-authored-by: あく --- .../nfc/scenes/nfc_scene_mf_ultralight_menu.c | 16 ++++---- .../main/nfc/scenes/nfc_scene_saved_menu.c | 4 +- firmware/targets/f7/api_symbols.csv | 1 + lib/nfc/nfc_types.c | 2 + lib/nfc/protocols/mifare_ultralight.c | 40 ++++++++++++++++--- lib/nfc/protocols/mifare_ultralight.h | 7 +++- 6 files changed, 56 insertions(+), 14 deletions(-) diff --git a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_menu.c b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_menu.c index c511e9dcbf..e7a494d273 100644 --- a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_menu.c +++ b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_menu.c @@ -19,7 +19,7 @@ void nfc_scene_mf_ultralight_menu_on_enter(void* context) { Submenu* submenu = nfc->submenu; MfUltralightData* data = &nfc->dev->dev_data.mf_ul_data; - if(!mf_ul_is_full_capture(data)) { + if(!mf_ul_is_full_capture(data) && data->type != MfUltralightTypeULC) { submenu_add_item( submenu, "Unlock", @@ -29,12 +29,14 @@ void nfc_scene_mf_ultralight_menu_on_enter(void* context) { } submenu_add_item( submenu, "Save", SubmenuIndexSave, nfc_scene_mf_ultralight_menu_submenu_callback, nfc); - submenu_add_item( - submenu, - "Emulate", - SubmenuIndexEmulate, - nfc_scene_mf_ultralight_menu_submenu_callback, - nfc); + if(mf_ul_emulation_supported(data)) { + submenu_add_item( + submenu, + "Emulate", + SubmenuIndexEmulate, + nfc_scene_mf_ultralight_menu_submenu_callback, + nfc); + } submenu_add_item( submenu, "Info", SubmenuIndexInfo, nfc_scene_mf_ultralight_menu_submenu_callback, nfc); diff --git a/applications/main/nfc/scenes/nfc_scene_saved_menu.c b/applications/main/nfc/scenes/nfc_scene_saved_menu.c index ba1f965398..e45dc4eb7d 100644 --- a/applications/main/nfc/scenes/nfc_scene_saved_menu.c +++ b/applications/main/nfc/scenes/nfc_scene_saved_menu.c @@ -42,7 +42,8 @@ void nfc_scene_saved_menu_on_enter(void* context) { nfc); } } else if( - nfc->dev->format == NfcDeviceSaveFormatMifareUl || + (nfc->dev->format == NfcDeviceSaveFormatMifareUl && + mf_ul_emulation_supported(&nfc->dev->dev_data.mf_ul_data)) || nfc->dev->format == NfcDeviceSaveFormatMifareClassic) { submenu_add_item( submenu, "Emulate", SubmenuIndexEmulate, nfc_scene_saved_menu_submenu_callback, nfc); @@ -72,6 +73,7 @@ void nfc_scene_saved_menu_on_enter(void* context) { submenu_add_item( submenu, "Info", SubmenuIndexInfo, nfc_scene_saved_menu_submenu_callback, nfc); if(nfc->dev->format == NfcDeviceSaveFormatMifareUl && + nfc->dev->dev_data.mf_ul_data.type != MfUltralightTypeULC && !mf_ul_is_full_capture(&nfc->dev->dev_data.mf_ul_data)) { submenu_add_item( submenu, diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index aebfc9072b..ccbaa53176 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -2013,6 +2013,7 @@ Function,-,mf_df_prepare_read_records,uint16_t,"uint8_t*, uint8_t, uint32_t, uin Function,-,mf_df_prepare_select_application,uint16_t,"uint8_t*, uint8_t[3]" Function,-,mf_df_read_card,_Bool,"FuriHalNfcTxRxContext*, MifareDesfireData*" Function,-,mf_ul_check_card_type,_Bool,"uint8_t, uint8_t, uint8_t" +Function,-,mf_ul_emulation_supported,_Bool,MfUltralightData* Function,-,mf_ul_is_full_capture,_Bool,MfUltralightData* Function,-,mf_ul_prepare_emulation,void,"MfUltralightEmulator*, MfUltralightData*" Function,-,mf_ul_prepare_emulation_response,_Bool,"uint8_t*, uint16_t, uint8_t*, uint16_t*, uint32_t*, void*" diff --git a/lib/nfc/nfc_types.c b/lib/nfc/nfc_types.c index 02ca85580d..96b92640f0 100644 --- a/lib/nfc/nfc_types.c +++ b/lib/nfc/nfc_types.c @@ -45,6 +45,8 @@ const char* nfc_mf_ul_type(MfUltralightType type, bool full_name) { return "NTAG I2C Plus 2K"; } else if(type == MfUltralightTypeNTAG203) { return "NTAG203"; + } else if(type == MfUltralightTypeULC) { + return "Mifare Ultralight C"; } else if(type == MfUltralightTypeUL11 && full_name) { return "Mifare Ultralight 11"; } else if(type == MfUltralightTypeUL21 && full_name) { diff --git a/lib/nfc/protocols/mifare_ultralight.c b/lib/nfc/protocols/mifare_ultralight.c index 6960bd2a18..266b6e2e2e 100644 --- a/lib/nfc/protocols/mifare_ultralight.c +++ b/lib/nfc/protocols/mifare_ultralight.c @@ -79,6 +79,8 @@ static MfUltralightFeatures mf_ul_get_features(MfUltralightType type) { MfUltralightSupportSectorSelect; case MfUltralightTypeNTAG203: return MfUltralightSupportCompatWrite | MfUltralightSupportCounterInMemory; + case MfUltralightTypeULC: + return MfUltralightSupportCompatWrite | MfUltralightSupport3DesAuth; default: // Assumed original MFUL 512-bit return MfUltralightSupportCompatWrite; @@ -95,6 +97,11 @@ static void mf_ul_set_version_ntag203(MfUltralightReader* reader, MfUltralightDa reader->pages_to_read = 42; } +static void mf_ul_set_version_ulc(MfUltralightReader* reader, MfUltralightData* data) { + data->type = MfUltralightTypeULC; + reader->pages_to_read = 48; +} + bool mf_ultralight_read_version( FuriHalNfcTxRxContext* tx_rx, MfUltralightReader* reader, @@ -175,7 +182,7 @@ bool mf_ultralight_authenticate(FuriHalNfcTxRxContext* tx_rx, uint32_t key, uint do { FURI_LOG_D(TAG, "Authenticating"); - tx_rx->tx_data[0] = MF_UL_AUTH; + tx_rx->tx_data[0] = MF_UL_PWD_AUTH; nfc_util_num2bytes(key, 4, &tx_rx->tx_data[1]); tx_rx->tx_bits = 40; tx_rx->tx_rx_type = FuriHalNfcTxRxTypeDefault; @@ -716,6 +723,21 @@ bool mf_ultralight_read_tearing_flags(FuriHalNfcTxRxContext* tx_rx, MfUltralight return flag_read == 2; } +static bool mf_ul_probe_3des_auth(FuriHalNfcTxRxContext* tx_rx) { + tx_rx->tx_data[0] = MF_UL_AUTHENTICATE_1; + tx_rx->tx_data[1] = 0; + tx_rx->tx_bits = 16; + tx_rx->tx_rx_type = FuriHalNfcTxRxTypeDefault; + bool rc = furi_hal_nfc_tx_rx(tx_rx, 50) && tx_rx->rx_bits == 9 * 8 && + tx_rx->rx_data[0] == 0xAF; + + // Reset just in case, we're not going to finish authenticating and need to if tag doesn't support auth + furi_hal_nfc_sleep(); + furi_hal_nfc_activate_nfca(300, NULL); + + return rc; +} + bool mf_ul_read_card( FuriHalNfcTxRxContext* tx_rx, MfUltralightReader* reader, @@ -733,16 +755,20 @@ bool mf_ul_read_card( mf_ultralight_read_signature(tx_rx, data); } } else { - // No GET_VERSION command, check for NTAG203 by reading last page (41) uint8_t dummy[16]; - if(mf_ultralight_read_pages_direct(tx_rx, 41, dummy)) { + // No GET_VERSION command, check if AUTHENTICATE command available (detect UL C). + if(mf_ul_probe_3des_auth(tx_rx)) { + mf_ul_set_version_ulc(reader, data); + } else if(mf_ultralight_read_pages_direct(tx_rx, 41, dummy)) { + // No AUTHENTICATE, check for NTAG203 by reading last page (41) mf_ul_set_version_ntag203(reader, data); - reader->supported_features = mf_ul_get_features(data->type); } else { // We're really an original Mifare Ultralight, reset tag for safety furi_hal_nfc_sleep(); furi_hal_nfc_activate_nfca(300, NULL); } + + reader->supported_features = mf_ul_get_features(data->type); } card_read = mf_ultralight_read_pages(tx_rx, reader, data); @@ -1228,6 +1254,10 @@ static void mf_ul_emulate_write( emulator->data_changed = true; } +bool mf_ul_emulation_supported(MfUltralightData* data) { + return data->type != MfUltralightTypeULC; +} + void mf_ul_reset_emulation(MfUltralightEmulator* emulator, bool is_power_cycle) { emulator->comp_write_cmd_started = false; emulator->sector_select_cmd_started = false; @@ -1732,7 +1762,7 @@ bool mf_ul_prepare_emulation_response( } } } - } else if(cmd == MF_UL_AUTH) { + } else if(cmd == MF_UL_PWD_AUTH) { if(emulator->supported_features & MfUltralightSupportAuth) { if(buff_rx_len == (1 + 4) * 8) { // Record password sent by PCD diff --git a/lib/nfc/protocols/mifare_ultralight.h b/lib/nfc/protocols/mifare_ultralight.h index 4ab22e89cb..d444fa7983 100644 --- a/lib/nfc/protocols/mifare_ultralight.h +++ b/lib/nfc/protocols/mifare_ultralight.h @@ -16,7 +16,8 @@ #define MF_UL_COMP_WRITE (0xA0) #define MF_UL_READ_CNT (0x39) #define MF_UL_INC_CNT (0xA5) -#define MF_UL_AUTH (0x1B) +#define MF_UL_AUTHENTICATE_1 (0x1A) +#define MF_UL_PWD_AUTH (0x1B) #define MF_UL_READ_SIG (0x3C) #define MF_UL_CHECK_TEARING (0x3E) #define MF_UL_READ_VCSL (0x4B) @@ -41,6 +42,7 @@ typedef enum { typedef enum { MfUltralightTypeUnknown, MfUltralightTypeNTAG203, + MfUltralightTypeULC, // Below have config pages and GET_VERSION support MfUltralightTypeUL11, MfUltralightTypeUL21, @@ -77,6 +79,7 @@ typedef enum { MfUltralightSupportAsciiMirror = 1 << 11, // NTAG203 counter that's in memory rather than through a command MfUltralightSupportCounterInMemory = 1 << 12, + MfUltralightSupport3DesAuth = 1 << 13, } MfUltralightFeatures; typedef enum { @@ -237,6 +240,8 @@ bool mf_ul_read_card( MfUltralightReader* reader, MfUltralightData* data); +bool mf_ul_emulation_supported(MfUltralightData* data); + void mf_ul_reset_emulation(MfUltralightEmulator* emulator, bool is_power_cycle); void mf_ul_prepare_emulation(MfUltralightEmulator* emulator, MfUltralightData* data); From 14a12b02efc595826114f78b75e5cb6559c9938e Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 26 May 2023 17:32:52 +0300 Subject: [PATCH 75/92] drop tx --- .../helpers/subrem_custom_event.h | 1 - .../scenes/subrem_scene_config.h | 3 +- .../scenes/subrem_scene_openmapfile.c | 1 - .../scenes/subrem_scene_remote.c | 130 ------------------ .../scenes/subrem_scene_start.c | 20 +-- .../subghz_remote_new/subghz_remote_app_i.c | 109 --------------- .../subghz_remote_new/subghz_remote_app_i.h | 7 - 7 files changed, 3 insertions(+), 268 deletions(-) delete mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_remote.c diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h index 46ab8ad547..b6f752ba0d 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h +++ b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h @@ -2,7 +2,6 @@ typedef enum { //SubmenuIndex - SubmenuIndexSubRemOpenMapFile, SubmenuIndexSubRemRemoteView, SubmenuIndexSubRemAbout, diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_config.h b/applications/external/subghz_remote_new/scenes/subrem_scene_config.h index 93d4de642e..a07b936969 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_config.h +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_config.h @@ -1,3 +1,2 @@ ADD_SCENE(subrem, start, Start) -ADD_SCENE(subrem, openmapfile, OpenMapFile) -ADD_SCENE(subrem, remote, Remote) \ No newline at end of file +ADD_SCENE(subrem, openmapfile, OpenMapFile) \ No newline at end of file diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c index ea5c14a0a5..8e6d9d0ddc 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c @@ -19,7 +19,6 @@ void subrem_scene_openmapfile_on_enter(void* context) { #endif } if(load_state == SubRemLoadMapStateOK || load_state == SubRemLoadMapStateNotAllOK) { - scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); } else { // TODO: Map Preset Reset if(!scene_manager_search_and_switch_to_previous_scene( diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c deleted file mode 100644 index c245832336..0000000000 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c +++ /dev/null @@ -1,130 +0,0 @@ -#include "../subghz_remote_app_i.h" -#include "../views/remote.h" - -#include - -#define TAG "SubRemScenRemote" - -void subrem_scene_remote_callback(SubRemCustomEvent event, void* context) { - furi_assert(context); - SubGhzRemoteApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, event); -} - -void subrem_scene_remote_raw_callback_end_tx(void* context) { - furi_assert(context); - SubGhzRemoteApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventViewRemoteForcedStop); -} - -static uint8_t subrem_scene_remote_event_to_index(SubRemCustomEvent event_id) { - uint8_t ret = 0; - - if(event_id == SubRemCustomEventViewRemoteStartUP) { - ret = SubRemSubKeyNameUp; - } else if(event_id == SubRemCustomEventViewRemoteStartDOWN) { - ret = SubRemSubKeyNameDown; - } else if(event_id == SubRemCustomEventViewRemoteStartLEFT) { - ret = SubRemSubKeyNameLeft; - } else if(event_id == SubRemCustomEventViewRemoteStartRIGHT) { - ret = SubRemSubKeyNameRight; - } else if(event_id == SubRemCustomEventViewRemoteStartOK) { - ret = SubRemSubKeyNameOk; - } - - return ret; -} - -static bool subrem_scene_remote_update_data_show(void* context) { - SubGhzRemoteApp* app = context; - bool ret = false; - - subrem_view_remote_add_data_to_show( - app->subrem_remote_view, - furi_string_get_cstr(app->subs_preset[0]->label), - furi_string_get_cstr(app->subs_preset[1]->label), - furi_string_get_cstr(app->subs_preset[2]->label), - furi_string_get_cstr(app->subs_preset[3]->label), - furi_string_get_cstr(app->subs_preset[4]->label)); - - return ret; -} - -void subrem_scene_remote_on_enter(void* context) { - SubGhzRemoteApp* app = context; - - subrem_scene_remote_update_data_show(app); - - subrem_view_remote_set_callback(app->subrem_remote_view, subrem_scene_remote_callback, app); - - view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDRemote); -} - -bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { - SubGhzRemoteApp* app = context; - if(event.type == SceneManagerEventTypeCustom) { - if(event.event == SubRemCustomEventViewRemoteBack) { - if(!scene_manager_search_and_switch_to_previous_scene( - app->scene_manager, SubRemSceneOpenMapFile)) { - if(!scene_manager_search_and_switch_to_previous_scene( - app->scene_manager, SubRemSceneStart)) { - scene_manager_stop(app->scene_manager); - view_dispatcher_stop(app->view_dispatcher); - } - } - return true; - } else if( - event.event == SubRemCustomEventViewRemoteStartUP || - event.event == SubRemCustomEventViewRemoteStartDOWN || - event.event == SubRemCustomEventViewRemoteStartLEFT || - event.event == SubRemCustomEventViewRemoteStartRIGHT || - event.event == SubRemCustomEventViewRemoteStartOK) { - // Start sending sub - subrem_tx_stop_sub(app, true); - app->chusen_sub = subrem_scene_remote_event_to_index(event.event); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateLoading); - if(subrem_tx_start_sub( - app, - app->subs_preset[app->chusen_sub], - subrem_scene_remote_raw_callback_end_tx)) { - subrem_view_remote_set_presed_btn(app->subrem_remote_view, app->chusen_sub); - subrem_view_remote_set_state( - app->subrem_remote_view, SubRemViewRemoteStateSending); - notification_message(app->notifications, &sequence_blink_start_magenta); - } else { - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); - notification_message(app->notifications, &sequence_blink_stop); - } - return true; - } else if(event.event == SubRemCustomEventViewRemoteForcedStop) { - subrem_tx_stop_sub(app, true); - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); - - notification_message(app->notifications, &sequence_blink_stop); - return true; - } else if(event.event == SubRemCustomEventViewRemoteStop) { - if(subrem_tx_stop_sub(app, false)) { - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); - - notification_message(app->notifications, &sequence_blink_stop); - } - return true; - } - } - // } else if(event.type == SceneManagerEventTypeTick) { - // } - return false; -} - -void subrem_scene_remote_on_exit(void* context) { - SubGhzRemoteApp* app = context; - - subrem_tx_stop_sub(app, true); - - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); - - notification_message(app->notifications, &sequence_blink_stop); -} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c index a4bfa50475..fd2d61c480 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c @@ -13,12 +13,6 @@ void subrem_scene_start_on_enter(void* context) { SubGhzRemoteApp* app = context; Submenu* submenu = app->submenu; - submenu_add_item( - submenu, - "Open Map File", - SubmenuIndexSubRemOpenMapFile, - subrem_scene_start_submenu_callback, - app); #if FURI_DEBUG submenu_add_item( submenu, @@ -37,7 +31,7 @@ void subrem_scene_start_on_enter(void* context) { // TODO: set scene state in subrem alloc // submenu_set_selected_item( // submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); - submenu_set_selected_item(submenu, SubmenuIndexSubRemOpenMapFile); + submenu_set_selected_item(submenu, 0); view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewSubmenu); } @@ -47,22 +41,12 @@ bool subrem_scene_start_on_event(void* context, SceneManagerEvent event) { SubGhzRemoteApp* app = context; bool consumed = false; - + UNUSED(app); if(event.type == SceneManagerEventTypeCustom) { - if(event.event == SubmenuIndexSubRemOpenMapFile) { - scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile); - consumed = true; - } // } else if(event.event == SubmenuIndexSubRemAbout) { // scene_manager_next_scene(app->scene_manager, SubRemSceneAbout); // consumed = true; // } -#if FURI_DEBUG - else if(event.event == SubmenuIndexSubRemRemoteView) { - scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); - consumed = true; - } -#endif } return consumed; diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index adc2219419..aa8983951b 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -163,115 +163,6 @@ bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev return saved; } -bool subrem_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback) { - furi_assert(app); - furi_assert(sub_preset); - bool ret = false; - - subrem_tx_stop_sub(app, true); - - if(sub_preset->type == SubGhzProtocolTypeUnknown) { - return false; - } - - FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); - - // subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); - // keeloq_reset_original_btn(); - // subghz_custom_btns_reset(); - - do { - flipper_format_rewind(sub_preset->fff_data); // - - app->transmitter = subghz_transmitter_alloc_init( - app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); - - if(app->transmitter) { - if(subghz_transmitter_deserialize(app->transmitter, sub_preset->fff_data) != - SubGhzProtocolStatusOk) { - FURI_LOG_E(TAG, "Deserialize error!"); - break; - } - furi_hal_subghz_reset(); - furi_hal_subghz_idle(); - furi_hal_subghz_load_custom_preset(sub_preset->freq_preset.data); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); - - furi_hal_subghz_idle(); - - furi_hal_subghz_set_frequency_and_path(sub_preset->freq_preset.frequency); - furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - - if(!furi_hal_subghz_tx()) { - FURI_LOG_E(TAG, "Sending not allowed"); - break; - } - - if(sub_preset->type == SubGhzProtocolTypeRAW) { - subghz_protocol_raw_file_encoder_worker_set_callback_end( - (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( - app->transmitter), - callback, - app); - } - - furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); - - ret = true; - } - } while(false); - - app->tx_running = ret; - - return ret; -} - -static void subghz_tx_stop(SubGhzRemoteApp* app) { - furi_assert(app); - - //Stop TX - furi_hal_subghz_stop_async_tx(); - - subghz_transmitter_stop(app->transmitter); - subghz_transmitter_free(app->transmitter); - furi_hal_subghz_idle(); -} - -bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { - furi_assert(app); - SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; - - if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) { - // SubRemSubKeyTypeRawKey)) { - if(app->tx_running) { - subghz_tx_stop(app); - - if(sub_preset->type == SubGhzProtocolTypeDynamic) { - subrem_save_protocol_to_file( - sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); - - // keeloq_reset_mfname(); - // keeloq_reset_kl_type(); - // keeloq_reset_original_btn(); - // subghz_custom_btns_reset(); - // star_line_reset_mfname(); - // star_line_reset_kl_type(); - } - - app->tx_running = false; - return true; - } - } - - return false; -} - static SubRemLoadMapState subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index 06abe659cb..1bcb79d8fd 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -76,10 +76,3 @@ typedef struct { } SubGhzRemoteApp; SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app); - -bool subrem_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback); - -bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced); \ No newline at end of file From c1eb968144f41319efb3e7b8cc4eea66327624fd Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 26 May 2023 17:39:43 +0300 Subject: [PATCH 76/92] Merge branch 'subrem' into subrem_configurator --- .../subghz_remote_new/application.fam | 11 +- .../helpers/subrem_custom_event.h | 39 +- .../helpers/subrem_presets.c | 180 ++++++ .../helpers/subrem_presets.h | 39 ++ .../subghz_remote_new/helpers/subrem_types.h | 17 +- .../subghz_remote_new/helpers/txrx/Readme.md | 4 + .../helpers/txrx/subghz_txrx.c | 563 ++++++++++++++++++ .../helpers/txrx/subghz_txrx.h | 318 ++++++++++ .../helpers/txrx/subghz_txrx_i.h | 29 + .../icons/DolphinNice_96x59.png | Bin 0 -> 2459 bytes .../{ => remote_scene}/ButtonDown_7x4.png | Bin .../{ => remote_scene}/ButtonLeft_4x7.png | Bin .../{ => remote_scene}/ButtonRight_4x7.png | Bin .../icons/{ => remote_scene}/ButtonUp_7x4.png | Bin .../icons/{ => remote_scene}/Ok_btn_9x9.png | Bin .../{ => remote_scene}/Pin_arrow_up_7x9.png | Bin .../{ => remote_scene}/Pin_cell_13x13.png | Bin .../icons/{ => remote_scene}/Pin_star_7x7.png | Bin .../icons/{ => remote_scene}/back_10px.png | Bin .../subghz_remote_new/icons/subrem_10px.png | Bin 0 -> 5000 bytes .../scenes/subrem_scene_config.h | 8 +- .../scenes/subrem_scene_edit_label.c | 133 +++++ .../scenes/subrem_scene_edit_menu.c | 123 ++++ .../scenes/subrem_scene_edit_preview.c | 74 +++ .../scenes/subrem_scene_edit_submenu.c | 54 ++ .../scenes/subrem_scene_enter_new_name.c | 71 +++ .../scenes/subrem_scene_open_map_file.c | 29 + .../scenes/subrem_scene_open_sub_file.c | 116 ++++ .../scenes/subrem_scene_openmapfile.c | 40 -- .../scenes/subrem_scene_start.c | 33 +- .../subghz_remote_new/subghz_remote_app.c | 87 ++- .../subghz_remote_new/subghz_remote_app_i.c | 395 +++++------- .../subghz_remote_new/subghz_remote_app_i.h | 57 +- .../subghz_remote_new/views/edit_menu.c | 290 +++++++++ .../subghz_remote_new/views/edit_menu.h | 29 + .../external/subghz_remote_new/views/remote.c | 184 +++--- .../external/subghz_remote_new/views/remote.h | 14 +- 37 files changed, 2455 insertions(+), 482 deletions(-) create mode 100644 applications/external/subghz_remote_new/helpers/subrem_presets.c create mode 100644 applications/external/subghz_remote_new/helpers/subrem_presets.h create mode 100644 applications/external/subghz_remote_new/helpers/txrx/Readme.md create mode 100644 applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.c create mode 100644 applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.h create mode 100644 applications/external/subghz_remote_new/helpers/txrx/subghz_txrx_i.h create mode 100644 applications/external/subghz_remote_new/icons/DolphinNice_96x59.png rename applications/external/subghz_remote_new/icons/{ => remote_scene}/ButtonDown_7x4.png (100%) rename applications/external/subghz_remote_new/icons/{ => remote_scene}/ButtonLeft_4x7.png (100%) rename applications/external/subghz_remote_new/icons/{ => remote_scene}/ButtonRight_4x7.png (100%) rename applications/external/subghz_remote_new/icons/{ => remote_scene}/ButtonUp_7x4.png (100%) rename applications/external/subghz_remote_new/icons/{ => remote_scene}/Ok_btn_9x9.png (100%) rename applications/external/subghz_remote_new/icons/{ => remote_scene}/Pin_arrow_up_7x9.png (100%) rename applications/external/subghz_remote_new/icons/{ => remote_scene}/Pin_cell_13x13.png (100%) rename applications/external/subghz_remote_new/icons/{ => remote_scene}/Pin_star_7x7.png (100%) rename applications/external/subghz_remote_new/icons/{ => remote_scene}/back_10px.png (100%) create mode 100644 applications/external/subghz_remote_new/icons/subrem_10px.png create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_edit_label.c create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_edit_menu.c create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_edit_preview.c create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_edit_submenu.c create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_enter_new_name.c create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_open_map_file.c create mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_open_sub_file.c delete mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c create mode 100644 applications/external/subghz_remote_new/views/edit_menu.c create mode 100644 applications/external/subghz_remote_new/views/edit_menu.h diff --git a/applications/external/subghz_remote_new/application.fam b/applications/external/subghz_remote_new/application.fam index f2cdd25b07..a232fb30f0 100644 --- a/applications/external/subghz_remote_new/application.fam +++ b/applications/external/subghz_remote_new/application.fam @@ -3,17 +3,14 @@ App( name="Sub-GHz Remote", apptype=FlipperAppType.EXTERNAL, entry_point="subghz_remote_app", - cdefines=[ - "APP_SUBGHZREMOTE", - "SUBREM_LIGHT", - ], requires=[ "gui", "dialogs", ], - icon="A_SubGHzRemote_14", - stack_size=4 * 1024, + stack_size=3 * 1024, order=50, - fap_category="Debug", + fap_description="Remote control for transmission multiple *.sub files", + fap_category="Debug", #"Sub-Ghz" fap_icon_assets="icons", + fap_icon="icons/subrem_10px.png", ) \ No newline at end of file diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h index b6f752ba0d..779458c203 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h +++ b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h @@ -1,11 +1,25 @@ #pragma once typedef enum { - //SubmenuIndex + SubRemEditMenuStateUP = 0, + SubRemEditMenuStateDOWN, + SubRemEditMenuStateLEFT, + SubRemEditMenuStateRIGHT, + SubRemEditMenuStateOK, +} SubRemEditMenuState; + +typedef enum { + // SubmenuIndex + SubmenuIndexSubRemEditMapFile = 0, + SubmenuIndexSubRemNewMapFile, SubmenuIndexSubRemRemoteView, SubmenuIndexSubRemAbout, - //SubRemCustomEvent + // EditSubmenuIndex + EditSubmenuIndexEditLabel, + EditSubmenuIndexEditFile, + + // SubRemCustomEvent SubRemCustomEventViewRemoteStartUP = 100, SubRemCustomEventViewRemoteStartDOWN, SubRemCustomEventViewRemoteStartLEFT, @@ -14,4 +28,25 @@ typedef enum { SubRemCustomEventViewRemoteBack, SubRemCustomEventViewRemoteStop, SubRemCustomEventViewRemoteForcedStop, + + SubRemCustomEventViewEditMenuBack, + SubRemCustomEventViewEditMenuUP, + SubRemCustomEventViewEditMenuDOWN, + SubRemCustomEventViewEditMenuEdit, + SubRemCustomEventViewEditMenuSave, + + SubRemCustomEventSceneEditsubmenu, + SubRemCustomEventSceneEditLabelInputDone, + SubRemCustomEventSceneEditLabelWidgetAcces, + SubRemCustomEventSceneEditLabelWidgetBack, + + SubRemCustomEventSceneEditOpenSubErrorPopup, + + SubRemCustomEventSceneEditPreviewSaved, + + SubRemCustomEventSceneNewName, + + // // SceneStates + // SubRemSceneOpenMapFileStateOpen, + // SubRemSceneOpenMapFileStateEdit, } SubRemCustomEvent; \ No newline at end of file diff --git a/applications/external/subghz_remote_new/helpers/subrem_presets.c b/applications/external/subghz_remote_new/helpers/subrem_presets.c new file mode 100644 index 0000000000..dc298c069a --- /dev/null +++ b/applications/external/subghz_remote_new/helpers/subrem_presets.c @@ -0,0 +1,180 @@ +#include "subrem_presets.h" + +#define TAG "SubRemPresets" + +SubRemSubFilePreset* subrem_sub_file_preset_alloc() { + SubRemSubFilePreset* sub_preset = malloc(sizeof(SubRemSubFilePreset)); + + sub_preset->fff_data = flipper_format_string_alloc(); + sub_preset->file_path = furi_string_alloc(); + sub_preset->protocaol_name = furi_string_alloc(); + sub_preset->label = furi_string_alloc(); + + sub_preset->freq_preset.name = furi_string_alloc(); + + sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; + + return sub_preset; +} + +void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { + furi_assert(sub_preset); + + furi_string_free(sub_preset->label); + furi_string_free(sub_preset->protocaol_name); + furi_string_free(sub_preset->file_path); + flipper_format_free(sub_preset->fff_data); + + furi_string_free(sub_preset->freq_preset.name); + + free(sub_preset); +} + +void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { + furi_assert(sub_preset); + + furi_string_set_str(sub_preset->label, ""); + furi_string_reset(sub_preset->protocaol_name); + furi_string_reset(sub_preset->file_path); + + Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); + stream_clean(fff_data_stream); + + sub_preset->type = SubGhzProtocolTypeUnknown; + sub_preset->load_state = SubRemLoadSubStateNotSet; +} + +SubRemLoadSubState subrem_sub_preset_load( + SubRemSubFilePreset* sub_preset, + SubGhzTxRx* txrx, + FlipperFormat* fff_data_file) { + furi_assert(sub_preset); + furi_assert(txrx); + furi_assert(fff_data_file); + + Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); + + SubRemLoadSubState ret; + FuriString* temp_str = furi_string_alloc(); + uint32_t temp_data32; + uint32_t repeat = 200; + + ret = SubRemLoadSubStateError; + + do { + stream_clean(fff_data_stream); + if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) { + FURI_LOG_E(TAG, "Missing or incorrect header"); + break; + } + + if(((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) || + (!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) && + temp_data32 == SUBGHZ_KEY_FILE_VERSION) { + } else { + FURI_LOG_E(TAG, "Type or version mismatch"); + break; + } + + SubGhzSetting* setting = subghz_txrx_get_setting(txrx); + + //Load frequency or using default from settings + ret = SubRemLoadSubStateErrorFreq; + if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { + FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); + sub_preset->freq_preset.frequency = subghz_setting_get_default_frequency(setting); + } else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { + FURI_LOG_E(TAG, "This frequency can only be used for RX"); + break; + } + sub_preset->freq_preset.frequency = temp_data32; + + //Load preset + ret = SubRemLoadSubStateErrorMod; + if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { + FURI_LOG_E(TAG, "Missing Preset"); + break; + } + + furi_string_set_str( + temp_str, subghz_txrx_get_preset_name(txrx, furi_string_get_cstr(temp_str))); + if(!strcmp(furi_string_get_cstr(temp_str), "")) { + break; + } + + if(!strcmp(furi_string_get_cstr(temp_str), "CUSTOM")) { + FURI_LOG_E(TAG, "CUSTOM preset is not supported"); + break; + // TODO Custom preset loading logic if need + // sub_preset->freq_preset.preset_index = + // subghz_setting_get_inx_preset_by_name(setting, furi_string_get_cstr(temp_str)); + } + + furi_string_set(sub_preset->freq_preset.name, temp_str); + + // Load protocol + ret = SubRemLoadSubStateErrorProtocol; + if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { + FURI_LOG_E(TAG, "Missing Protocol"); + break; + } + + FlipperFormat* fff_data = sub_preset->fff_data; + if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) { + //if RAW + subghz_protocol_raw_gen_fff_data( + fff_data, furi_string_get_cstr(sub_preset->file_path)); + } else { + stream_copy_full( + flipper_format_get_raw_stream(fff_data_file), + flipper_format_get_raw_stream(fff_data)); + } + + if(subghz_txrx_load_decoder_by_name_protocol(txrx, furi_string_get_cstr(temp_str))) { + SubGhzProtocolStatus status = + subghz_protocol_decoder_base_deserialize(subghz_txrx_get_decoder(txrx), fff_data); + if(status != SubGhzProtocolStatusOk) { + break; + } + } else { + FURI_LOG_E(TAG, "Protocol not found"); + break; + } + + const SubGhzProtocol* protocol = subghz_txrx_get_decoder(txrx)->protocol; + + if(protocol->flag & SubGhzProtocolFlag_Send) { + if((protocol->type == SubGhzProtocolTypeStatic) || + (protocol->type == SubGhzProtocolTypeDynamic) || + // TODO: BINRAW It probably works, but checks are needed. + // (protocol->type == SubGhzProtocolTypeBinRAW) || + (protocol->type == SubGhzProtocolTypeRAW)) { + sub_preset->type = protocol->type; + } else { + FURI_LOG_E(TAG, "Unsuported Protocol"); + break; + } + + furi_string_set(sub_preset->protocaol_name, temp_str); + } else { + FURI_LOG_E(TAG, "Protocol does not support transmission"); + break; + } + + if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + + ret = SubRemLoadSubStateOK; + +#if FURI_DEBUG + FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); +#endif + } while(false); + + furi_string_free(temp_str); + sub_preset->load_state = ret; + return ret; +} diff --git a/applications/external/subghz_remote_new/helpers/subrem_presets.h b/applications/external/subghz_remote_new/helpers/subrem_presets.h new file mode 100644 index 0000000000..d66181b90d --- /dev/null +++ b/applications/external/subghz_remote_new/helpers/subrem_presets.h @@ -0,0 +1,39 @@ +#pragma once + +#include "subrem_types.h" +#include "txrx/subghz_txrx.h" + +#include +#include + +typedef struct { + FuriString* name; + uint32_t frequency; + // size_t preset_index; // Need for custom preset +} FreqPreset; + +// Sub File preset +typedef struct { + FlipperFormat* fff_data; + FreqPreset freq_preset; + FuriString* file_path; + FuriString* protocaol_name; + FuriString* label; + SubGhzProtocolType type; + SubRemLoadSubState load_state; +} SubRemSubFilePreset; + +typedef struct { + SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; +} SubRemMapPreset; + +SubRemSubFilePreset* subrem_sub_file_preset_alloc(); + +void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset); + +void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset); + +SubRemLoadSubState subrem_sub_preset_load( + SubRemSubFilePreset* sub_preset, + SubGhzTxRx* txrx, + FlipperFormat* fff_data_file); diff --git a/applications/external/subghz_remote_new/helpers/subrem_types.h b/applications/external/subghz_remote_new/helpers/subrem_types.h index 13b42897f6..b43f8499d8 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_types.h +++ b/applications/external/subghz_remote_new/helpers/subrem_types.h @@ -3,9 +3,8 @@ #include #include -// TODO: File version/type logic -// #define SUBREM_APP_APP_FILE_VERSION 1 -// #define SUBREM_APP_APP_FILE_TYPE "Flipper SubRem Map file" +#define SUBREM_APP_APP_FILE_VERSION 1 +#define SUBREM_APP_APP_FILE_TYPE "Flipper SubRem Map file" #define SUBREM_APP_EXTENSION ".txt" typedef enum { @@ -18,17 +17,19 @@ typedef enum { } SubRemSubKeyName; typedef enum { - SubRemViewSubmenu, - SubRemViewWidget, - SubRemViewPopup, - SubRemViewTextInput, + SubRemViewIDSubmenu, + SubRemViewIDWidget, + SubRemViewIDPopup, + SubRemViewIDTextInput, SubRemViewIDRemote, + SubRemViewIDEditMenu, } SubRemViewID; typedef enum { - SubRemLoadSubStateNotSet, + SubRemLoadSubStateNotSet = 0, SubRemLoadSubStatePreloaded, SubRemLoadSubStateError, + SubRemLoadSubStateErrorIncorectPath, SubRemLoadSubStateErrorNoFile, SubRemLoadSubStateErrorFreq, SubRemLoadSubStateErrorMod, diff --git a/applications/external/subghz_remote_new/helpers/txrx/Readme.md b/applications/external/subghz_remote_new/helpers/txrx/Readme.md new file mode 100644 index 0000000000..9181601980 --- /dev/null +++ b/applications/external/subghz_remote_new/helpers/txrx/Readme.md @@ -0,0 +1,4 @@ +This is part of the official `SubGhz` app from [flipperzero-firmware](https://github.com/flipperdevices/flipperzero-firmware/tree/3217f286f03da119398586daf94c0723d28b872a/applications/main/subghz) + +With changes from [unleashed-firmware +](https://github.com/DarkFlippers/unleashed-firmware/tree/3eac6ccd48a3851cf5d63bf7899b387a293e5319/applications/main/subghz) \ No newline at end of file diff --git a/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.c b/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.c new file mode 100644 index 0000000000..c1f519ba0d --- /dev/null +++ b/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.c @@ -0,0 +1,563 @@ +#include "subghz_txrx_i.h" +#include + +#define TAG "SubGhz" + +SubGhzTxRx* subghz_txrx_alloc() { + SubGhzTxRx* instance = malloc(sizeof(SubGhzTxRx)); + instance->setting = subghz_setting_alloc(); + subghz_setting_load(instance->setting, EXT_PATH("subghz/assets/setting_user")); + + instance->preset = malloc(sizeof(SubGhzRadioPreset)); + instance->preset->name = furi_string_alloc(); + subghz_txrx_set_preset( + instance, "AM650", subghz_setting_get_default_frequency(instance->setting), NULL, 0); + + instance->txrx_state = SubGhzTxRxStateSleep; + + subghz_txrx_hopper_set_state(instance, SubGhzHopperStateOFF); + subghz_txrx_speaker_set_state(instance, SubGhzSpeakerStateDisable); + subghz_txrx_set_debug_pin_state(instance, false); + + instance->worker = subghz_worker_alloc(); + instance->fff_data = flipper_format_string_alloc(); + + instance->environment = subghz_environment_alloc(); + instance->is_database_loaded = subghz_environment_load_keystore( + instance->environment, EXT_PATH("subghz/assets/keeloq_mfcodes")); + subghz_environment_load_keystore( + instance->environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user")); + subghz_environment_set_came_atomo_rainbow_table_file_name( + instance->environment, EXT_PATH("subghz/assets/came_atomo")); + subghz_environment_set_alutech_at_4n_rainbow_table_file_name( + instance->environment, EXT_PATH("subghz/assets/alutech_at_4n")); + subghz_environment_set_nice_flor_s_rainbow_table_file_name( + instance->environment, EXT_PATH("subghz/assets/nice_flor_s")); + subghz_environment_set_protocol_registry( + instance->environment, (void*)&subghz_protocol_registry); + instance->receiver = subghz_receiver_alloc_init(instance->environment); + + subghz_worker_set_overrun_callback( + instance->worker, (SubGhzWorkerOverrunCallback)subghz_receiver_reset); + subghz_worker_set_pair_callback( + instance->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode); + subghz_worker_set_context(instance->worker, instance->receiver); + + return instance; +} + +void subghz_txrx_free(SubGhzTxRx* instance) { + furi_assert(instance); + + subghz_worker_free(instance->worker); + subghz_receiver_free(instance->receiver); + subghz_environment_free(instance->environment); + flipper_format_free(instance->fff_data); + furi_string_free(instance->preset->name); + subghz_setting_free(instance->setting); + free(instance->preset); + free(instance); +} + +bool subghz_txrx_is_database_loaded(SubGhzTxRx* instance) { + furi_assert(instance); + return instance->is_database_loaded; +} + +void subghz_txrx_set_preset( + SubGhzTxRx* instance, + const char* preset_name, + uint32_t frequency, + uint8_t* preset_data, + size_t preset_data_size) { + furi_assert(instance); + furi_string_set(instance->preset->name, preset_name); + SubGhzRadioPreset* preset = instance->preset; + preset->frequency = frequency; + preset->data = preset_data; + preset->data_size = preset_data_size; +} + +const char* subghz_txrx_get_preset_name(SubGhzTxRx* instance, const char* preset) { + UNUSED(instance); + const char* preset_name = ""; + if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) { + preset_name = "AM270"; + } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) { + preset_name = "AM650"; + } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) { + preset_name = "FM238"; + } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) { + preset_name = "FM476"; + } else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) { + preset_name = "CUSTOM"; + } else { + FURI_LOG_E(TAG, "Unknown preset"); + } + return preset_name; +} + +SubGhzRadioPreset subghz_txrx_get_preset(SubGhzTxRx* instance) { + furi_assert(instance); + return *instance->preset; +} + +void subghz_txrx_get_frequency_and_modulation( + SubGhzTxRx* instance, + FuriString* frequency, + FuriString* modulation, + bool long_name) { + furi_assert(instance); + SubGhzRadioPreset* preset = instance->preset; + if(frequency != NULL) { + furi_string_printf( + frequency, + "%03ld.%02ld", + preset->frequency / 1000000 % 1000, + preset->frequency / 10000 % 100); + } + if(modulation != NULL) { + if(long_name) { + furi_string_printf(modulation, "%s", furi_string_get_cstr(preset->name)); + } else { + furi_string_printf(modulation, "%.2s", furi_string_get_cstr(preset->name)); + } + } +} + +static void subghz_txrx_begin(SubGhzTxRx* instance, uint8_t* preset_data) { + furi_assert(instance); + furi_hal_subghz_reset(); + furi_hal_subghz_idle(); + furi_hal_subghz_load_custom_preset(preset_data); + furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); + instance->txrx_state = SubGhzTxRxStateIDLE; +} + +static uint32_t subghz_txrx_rx(SubGhzTxRx* instance, uint32_t frequency) { + furi_assert(instance); + if(!furi_hal_subghz_is_frequency_valid(frequency)) { + furi_crash("SubGhz: Incorrect RX frequency."); + } + furi_assert( + instance->txrx_state != SubGhzTxRxStateRx && instance->txrx_state != SubGhzTxRxStateSleep); + + furi_hal_subghz_idle(); + uint32_t value = furi_hal_subghz_set_frequency_and_path(frequency); + furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); + furi_hal_subghz_flush_rx(); + subghz_txrx_speaker_on(instance); + furi_hal_subghz_rx(); + + furi_hal_subghz_start_async_rx(subghz_worker_rx_callback, instance->worker); + subghz_worker_start(instance->worker); + instance->txrx_state = SubGhzTxRxStateRx; + return value; +} + +static void subghz_txrx_idle(SubGhzTxRx* instance) { + furi_assert(instance); + furi_assert(instance->txrx_state != SubGhzTxRxStateSleep); + furi_hal_subghz_idle(); + subghz_txrx_speaker_off(instance); + instance->txrx_state = SubGhzTxRxStateIDLE; +} + +static void subghz_txrx_rx_end(SubGhzTxRx* instance) { + furi_assert(instance); + furi_assert(instance->txrx_state == SubGhzTxRxStateRx); + + if(subghz_worker_is_running(instance->worker)) { + subghz_worker_stop(instance->worker); + furi_hal_subghz_stop_async_rx(); + } + furi_hal_subghz_idle(); + subghz_txrx_speaker_off(instance); + instance->txrx_state = SubGhzTxRxStateIDLE; +} + +void subghz_txrx_sleep(SubGhzTxRx* instance) { + furi_assert(instance); + furi_hal_subghz_sleep(); + instance->txrx_state = SubGhzTxRxStateSleep; +} + +static bool subghz_txrx_tx(SubGhzTxRx* instance, uint32_t frequency) { + furi_assert(instance); + if(!furi_hal_subghz_is_frequency_valid(frequency)) { + furi_crash("SubGhz: Incorrect TX frequency."); + } + furi_assert(instance->txrx_state != SubGhzTxRxStateSleep); + furi_hal_subghz_idle(); + furi_hal_subghz_set_frequency_and_path(frequency); + furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); + furi_hal_gpio_init( + furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); + bool ret = furi_hal_subghz_tx(); + if(ret) { + subghz_txrx_speaker_on(instance); + instance->txrx_state = SubGhzTxRxStateTx; + } + + return ret; +} + +SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format) { + furi_assert(instance); + furi_assert(flipper_format); + + subghz_txrx_stop(instance); + + SubGhzTxRxStartTxState ret = SubGhzTxRxStartTxStateErrorParserOthers; + FuriString* temp_str = furi_string_alloc(); + uint32_t repeat = 200; + do { + if(!flipper_format_rewind(flipper_format)) { + FURI_LOG_E(TAG, "Rewind error"); + break; + } + if(!flipper_format_read_string(flipper_format, "Protocol", temp_str)) { + FURI_LOG_E(TAG, "Missing Protocol"); + break; + } + if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + ret = SubGhzTxRxStartTxStateOk; + + SubGhzRadioPreset* preset = instance->preset; + instance->transmitter = + subghz_transmitter_alloc_init(instance->environment, furi_string_get_cstr(temp_str)); + + if(instance->transmitter) { + if(subghz_transmitter_deserialize(instance->transmitter, flipper_format) == + SubGhzProtocolStatusOk) { + if(strcmp(furi_string_get_cstr(preset->name), "") != 0) { + subghz_txrx_begin( + instance, + subghz_setting_get_preset_data_by_name( + instance->setting, furi_string_get_cstr(preset->name))); + if(preset->frequency) { + if(!subghz_txrx_tx(instance, preset->frequency)) { + FURI_LOG_E(TAG, "Only Rx"); + ret = SubGhzTxRxStartTxStateErrorOnlyRx; + } + } else { + ret = SubGhzTxRxStartTxStateErrorParserOthers; + } + + } else { + FURI_LOG_E( + TAG, "Unknown name preset \" %s \"", furi_string_get_cstr(preset->name)); + ret = SubGhzTxRxStartTxStateErrorParserOthers; + } + + if(ret == SubGhzTxRxStartTxStateOk) { + //Start TX + furi_hal_subghz_start_async_tx( + subghz_transmitter_yield, instance->transmitter); + } + } else { + ret = SubGhzTxRxStartTxStateErrorParserOthers; + } + } else { + ret = SubGhzTxRxStartTxStateErrorParserOthers; + } + if(ret != SubGhzTxRxStartTxStateOk) { + subghz_transmitter_free(instance->transmitter); + if(instance->txrx_state != SubGhzTxRxStateIDLE) { + subghz_txrx_idle(instance); + } + } + + } while(false); + furi_string_free(temp_str); + return ret; +} + +void subghz_txrx_rx_start(SubGhzTxRx* instance) { + furi_assert(instance); + subghz_txrx_stop(instance); + subghz_txrx_begin( + instance, + subghz_setting_get_preset_data_by_name( + subghz_txrx_get_setting(instance), furi_string_get_cstr(instance->preset->name))); + subghz_txrx_rx(instance, instance->preset->frequency); +} + +void subghz_txrx_set_need_save_callback( + SubGhzTxRx* instance, + SubGhzTxRxNeedSaveCallback callback, + void* context) { + furi_assert(instance); + instance->need_save_callback = callback; + instance->need_save_context = context; +} + +static void subghz_txrx_tx_stop(SubGhzTxRx* instance) { + furi_assert(instance); + furi_assert(instance->txrx_state == SubGhzTxRxStateTx); + //Stop TX + furi_hal_subghz_stop_async_tx(); + subghz_transmitter_stop(instance->transmitter); + subghz_transmitter_free(instance->transmitter); + + //if protocol dynamic then we save the last upload + if(instance->decoder_result->protocol->type == SubGhzProtocolTypeDynamic) { + if(instance->need_save_callback) { + instance->need_save_callback(instance->need_save_context); + } + } + subghz_txrx_idle(instance); + subghz_txrx_speaker_off(instance); + //Todo: Show message + // notification_message(notifications, &sequence_reset_red); +} + +FlipperFormat* subghz_txrx_get_fff_data(SubGhzTxRx* instance) { + furi_assert(instance); + return instance->fff_data; +} + +SubGhzSetting* subghz_txrx_get_setting(SubGhzTxRx* instance) { + furi_assert(instance); + return instance->setting; +} + +void subghz_txrx_stop(SubGhzTxRx* instance) { + furi_assert(instance); + + switch(instance->txrx_state) { + case SubGhzTxRxStateTx: + subghz_txrx_tx_stop(instance); + subghz_txrx_speaker_unmute(instance); + break; + case SubGhzTxRxStateRx: + subghz_txrx_rx_end(instance); + subghz_txrx_speaker_mute(instance); + break; + + default: + break; + } +} + +void subghz_txrx_hopper_update(SubGhzTxRx* instance) { + furi_assert(instance); + + switch(instance->hopper_state) { + case SubGhzHopperStateOFF: + case SubGhzHopperStatePause: + return; + case SubGhzHopperStateRSSITimeOut: + if(instance->hopper_timeout != 0) { + instance->hopper_timeout--; + return; + } + break; + default: + break; + } + float rssi = -127.0f; + if(instance->hopper_state != SubGhzHopperStateRSSITimeOut) { + // See RSSI Calculation timings in CC1101 17.3 RSSI + rssi = furi_hal_subghz_get_rssi(); + + // Stay if RSSI is high enough + if(rssi > -90.0f) { + instance->hopper_timeout = 10; + instance->hopper_state = SubGhzHopperStateRSSITimeOut; + return; + } + } else { + instance->hopper_state = SubGhzHopperStateRunning; + } + // Select next frequency + if(instance->hopper_idx_frequency < + subghz_setting_get_hopper_frequency_count(instance->setting) - 1) { + instance->hopper_idx_frequency++; + } else { + instance->hopper_idx_frequency = 0; + } + + if(instance->txrx_state == SubGhzTxRxStateRx) { + subghz_txrx_rx_end(instance); + }; + if(instance->txrx_state == SubGhzTxRxStateIDLE) { + subghz_receiver_reset(instance->receiver); + instance->preset->frequency = + subghz_setting_get_hopper_frequency(instance->setting, instance->hopper_idx_frequency); + subghz_txrx_rx(instance, instance->preset->frequency); + } +} + +SubGhzHopperState subghz_txrx_hopper_get_state(SubGhzTxRx* instance) { + furi_assert(instance); + return instance->hopper_state; +} + +void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state) { + furi_assert(instance); + instance->hopper_state = state; +} + +void subghz_txrx_hopper_unpause(SubGhzTxRx* instance) { + furi_assert(instance); + if(instance->hopper_state == SubGhzHopperStatePause) { + instance->hopper_state = SubGhzHopperStateRunning; + } +} + +void subghz_txrx_hopper_pause(SubGhzTxRx* instance) { + furi_assert(instance); + if(instance->hopper_state == SubGhzHopperStateRunning) { + instance->hopper_state = SubGhzHopperStatePause; + } +} + +void subghz_txrx_speaker_on(SubGhzTxRx* instance) { + furi_assert(instance); + if(instance->debug_pin_state) { + furi_hal_subghz_set_async_mirror_pin(&gpio_ibutton); + } + + if(instance->speaker_state == SubGhzSpeakerStateEnable) { + if(furi_hal_speaker_acquire(30)) { + if(!instance->debug_pin_state) { + furi_hal_subghz_set_async_mirror_pin(&gpio_speaker); + } + } else { + instance->speaker_state = SubGhzSpeakerStateDisable; + } + } +} + +void subghz_txrx_speaker_off(SubGhzTxRx* instance) { + furi_assert(instance); + if(instance->debug_pin_state) { + furi_hal_subghz_set_async_mirror_pin(NULL); + } + if(instance->speaker_state != SubGhzSpeakerStateDisable) { + if(furi_hal_speaker_is_mine()) { + if(!instance->debug_pin_state) { + furi_hal_subghz_set_async_mirror_pin(NULL); + } + furi_hal_speaker_release(); + if(instance->speaker_state == SubGhzSpeakerStateShutdown) + instance->speaker_state = SubGhzSpeakerStateDisable; + } + } +} + +void subghz_txrx_speaker_mute(SubGhzTxRx* instance) { + furi_assert(instance); + if(instance->debug_pin_state) { + furi_hal_subghz_set_async_mirror_pin(NULL); + } + if(instance->speaker_state == SubGhzSpeakerStateEnable) { + if(furi_hal_speaker_is_mine()) { + if(!instance->debug_pin_state) { + furi_hal_subghz_set_async_mirror_pin(NULL); + } + } + } +} + +void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) { + furi_assert(instance); + if(instance->debug_pin_state) { + furi_hal_subghz_set_async_mirror_pin(&gpio_ibutton); + } + if(instance->speaker_state == SubGhzSpeakerStateEnable) { + if(furi_hal_speaker_is_mine()) { + if(!instance->debug_pin_state) { + furi_hal_subghz_set_async_mirror_pin(&gpio_speaker); + } + } + } +} + +void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState state) { + furi_assert(instance); + instance->speaker_state = state; +} + +SubGhzSpeakerState subghz_txrx_speaker_get_state(SubGhzTxRx* instance) { + furi_assert(instance); + return instance->speaker_state; +} + +bool subghz_txrx_load_decoder_by_name_protocol(SubGhzTxRx* instance, const char* name_protocol) { + furi_assert(instance); + furi_assert(name_protocol); + bool res = false; + instance->decoder_result = + subghz_receiver_search_decoder_base_by_name(instance->receiver, name_protocol); + if(instance->decoder_result) { + res = true; + } + return res; +} + +SubGhzProtocolDecoderBase* subghz_txrx_get_decoder(SubGhzTxRx* instance) { + furi_assert(instance); + return instance->decoder_result; +} + +bool subghz_txrx_protocol_is_serializable(SubGhzTxRx* instance) { + furi_assert(instance); + return ( + (instance->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) == + SubGhzProtocolFlag_Save); +} + +bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type) { + furi_assert(instance); + const SubGhzProtocol* protocol = instance->decoder_result->protocol; + if(check_type) { + return ( + ((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) && + protocol->encoder->deserialize && protocol->type == SubGhzProtocolTypeStatic); + } + return ( + ((protocol->flag & SubGhzProtocolFlag_Send) == SubGhzProtocolFlag_Send) && + protocol->encoder->deserialize); +} + +void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag filter) { + furi_assert(instance); + subghz_receiver_set_filter(instance->receiver, filter); +} + +void subghz_txrx_set_rx_calback( + SubGhzTxRx* instance, + SubGhzReceiverCallback callback, + void* context) { + subghz_receiver_set_rx_callback(instance->receiver, callback, context); +} + +void subghz_txrx_set_raw_file_encoder_worker_callback_end( + SubGhzTxRx* instance, + SubGhzProtocolEncoderRAWCallbackEnd callback, + void* context) { + subghz_protocol_raw_file_encoder_worker_set_callback_end( + (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance(instance->transmitter), + callback, + context); +} + +void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state) { + furi_assert(instance); + instance->debug_pin_state = state; +} + +bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance) { + furi_assert(instance); + return instance->debug_pin_state; +} + +SubGhzReceiver* subghz_txrx_get_receiver(SubGhzTxRx* instance) { + furi_assert(instance); + return instance->receiver; +} \ No newline at end of file diff --git a/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.h b/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.h new file mode 100644 index 0000000000..b2ebcc5f30 --- /dev/null +++ b/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.h @@ -0,0 +1,318 @@ +#pragma once + +#include +#include +#include +#include +#include + +typedef struct SubGhzTxRx SubGhzTxRx; + +typedef void (*SubGhzTxRxNeedSaveCallback)(void* context); + +typedef enum { + SubGhzTxRxStartTxStateOk, + SubGhzTxRxStartTxStateErrorOnlyRx, + SubGhzTxRxStartTxStateErrorParserOthers, +} SubGhzTxRxStartTxState; + +// Type from subghz_types.h need for txrx working +/** SubGhzTxRx state */ +typedef enum { + SubGhzTxRxStateIDLE, + SubGhzTxRxStateRx, + SubGhzTxRxStateTx, + SubGhzTxRxStateSleep, +} SubGhzTxRxState; + +/** SubGhzHopperState state */ +typedef enum { + SubGhzHopperStateOFF, + SubGhzHopperStateRunning, + SubGhzHopperStatePause, + SubGhzHopperStateRSSITimeOut, +} SubGhzHopperState; + +/** SubGhzSpeakerState state */ +typedef enum { + SubGhzSpeakerStateDisable, + SubGhzSpeakerStateShutdown, + SubGhzSpeakerStateEnable, +} SubGhzSpeakerState; + +/** + * Allocate SubGhzTxRx + * + * @return SubGhzTxRx* pointer to SubGhzTxRx + */ +SubGhzTxRx* subghz_txrx_alloc(); + +/** + * Free SubGhzTxRx + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_free(SubGhzTxRx* instance); + +/** + * Check if the database is loaded + * + * @param instance Pointer to a SubGhzTxRx + * @return bool True if the database is loaded + */ +bool subghz_txrx_is_database_loaded(SubGhzTxRx* instance); + +/** + * Set preset + * + * @param instance Pointer to a SubGhzTxRx + * @param preset_name Name of preset + * @param frequency Frequency in Hz + * @param preset_data Data of preset + * @param preset_data_size Size of preset data + */ +void subghz_txrx_set_preset( + SubGhzTxRx* instance, + const char* preset_name, + uint32_t frequency, + uint8_t* preset_data, + size_t preset_data_size); + +/** + * Get name of preset + * + * @param instance Pointer to a SubGhzTxRx + * @param preset String of preset + * @return const char* Name of preset + */ +const char* subghz_txrx_get_preset_name(SubGhzTxRx* instance, const char* preset); + +/** + * Get of preset + * + * @param instance Pointer to a SubGhzTxRx + * @return SubGhzRadioPreset Preset + */ +SubGhzRadioPreset subghz_txrx_get_preset(SubGhzTxRx* instance); + +/** + * Get string frequency and modulation + * + * @param instance Pointer to a SubGhzTxRx + * @param frequency Pointer to a string frequency + * @param modulation Pointer to a string modulation + */ +void subghz_txrx_get_frequency_and_modulation( + SubGhzTxRx* instance, + FuriString* frequency, + FuriString* modulation, + bool long_name); + +/** + * Start TX CC1101 + * + * @param instance Pointer to a SubGhzTxRx + * @param flipper_format Pointer to a FlipperFormat + * @return SubGhzTxRxStartTxState + */ +SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format); + +/** + * Start RX CC1101 + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_rx_start(SubGhzTxRx* instance); + +/** + * Stop TX/RX CC1101 + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_stop(SubGhzTxRx* instance); + +/** + * Set sleep mode CC1101 + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_sleep(SubGhzTxRx* instance); + +/** + * Update frequency CC1101 in automatic mode (hopper) + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_hopper_update(SubGhzTxRx* instance); + +/** + * Get state hopper + * + * @param instance Pointer to a SubGhzTxRx + * @return SubGhzHopperState + */ +SubGhzHopperState subghz_txrx_hopper_get_state(SubGhzTxRx* instance); + +/** + * Set state hopper + * + * @param instance Pointer to a SubGhzTxRx + * @param state State hopper + */ +void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state); + +/** + * Unpause hopper + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_hopper_unpause(SubGhzTxRx* instance); + +/** + * Set pause hopper + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_hopper_pause(SubGhzTxRx* instance); + +/** + * Speaker on + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_speaker_on(SubGhzTxRx* instance); + +/** + * Speaker off + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_speaker_off(SubGhzTxRx* instance); + +/** + * Speaker mute + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_speaker_mute(SubGhzTxRx* instance); + +/** + * Speaker unmute + * + * @param instance Pointer to a SubGhzTxRx + */ +void subghz_txrx_speaker_unmute(SubGhzTxRx* instance); + +/** + * Set state speaker + * + * @param instance Pointer to a SubGhzTxRx + * @param state State speaker + */ +void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState state); + +/** + * Get state speaker + * + * @param instance Pointer to a SubGhzTxRx + * @return SubGhzSpeakerState + */ +SubGhzSpeakerState subghz_txrx_speaker_get_state(SubGhzTxRx* instance); + +/** + * load decoder by name protocol + * + * @param instance Pointer to a SubGhzTxRx + * @param name_protocol Name protocol + * @return bool True if the decoder is loaded + */ +bool subghz_txrx_load_decoder_by_name_protocol(SubGhzTxRx* instance, const char* name_protocol); + +/** + * Get decoder + * + * @param instance Pointer to a SubGhzTxRx + * @return SubGhzProtocolDecoderBase* Pointer to a SubGhzProtocolDecoderBase + */ +SubGhzProtocolDecoderBase* subghz_txrx_get_decoder(SubGhzTxRx* instance); + +/** + * Set callback for save data + * + * @param instance Pointer to a SubGhzTxRx + * @param callback Callback for save data + * @param context Context for callback + */ +void subghz_txrx_set_need_save_callback( + SubGhzTxRx* instance, + SubGhzTxRxNeedSaveCallback callback, + void* context); + +/** + * Get pointer to a load data key + * + * @param instance Pointer to a SubGhzTxRx + * @return FlipperFormat* + */ +FlipperFormat* subghz_txrx_get_fff_data(SubGhzTxRx* instance); + +/** + * Get pointer to a SugGhzSetting + * + * @param instance Pointer to a SubGhzTxRx + * @return SubGhzSetting* + */ +SubGhzSetting* subghz_txrx_get_setting(SubGhzTxRx* instance); + +/** + * Is it possible to save this protocol + * + * @param instance Pointer to a SubGhzTxRx + * @return bool True if it is possible to save this protocol + */ +bool subghz_txrx_protocol_is_serializable(SubGhzTxRx* instance); + +/** + * Is it possible to send this protocol + * + * @param instance Pointer to a SubGhzTxRx + * @return bool True if it is possible to send this protocol + */ +bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type); + +/** + * Set filter, what types of decoder to use + * + * @param instance Pointer to a SubGhzTxRx + * @param filter Filter + */ +void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag filter); + +/** + * Set callback for receive data + * + * @param instance Pointer to a SubGhzTxRx + * @param callback Callback for receive data + * @param context Context for callback + */ +void subghz_txrx_set_rx_calback( + SubGhzTxRx* instance, + SubGhzReceiverCallback callback, + void* context); + +/** + * Set callback for Raw decoder, end of data transfer + * + * @param instance Pointer to a SubGhzTxRx + * @param callback Callback for Raw decoder, end of data transfer + * @param context Context for callback + */ +void subghz_txrx_set_raw_file_encoder_worker_callback_end( + SubGhzTxRx* instance, + SubGhzProtocolEncoderRAWCallbackEnd callback, + void* context); + +void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state); +bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance); + +SubGhzReceiver* subghz_txrx_get_receiver(SubGhzTxRx* instance); // TODO use only in DecodeRaw diff --git a/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx_i.h b/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx_i.h new file mode 100644 index 0000000000..680d271585 --- /dev/null +++ b/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx_i.h @@ -0,0 +1,29 @@ + +#pragma once +#include "subghz_txrx.h" + +struct SubGhzTxRx { + SubGhzWorker* worker; + + SubGhzEnvironment* environment; + SubGhzReceiver* receiver; + SubGhzTransmitter* transmitter; + SubGhzProtocolDecoderBase* decoder_result; + FlipperFormat* fff_data; + + SubGhzRadioPreset* preset; + SubGhzSetting* setting; + + uint8_t hopper_timeout; + uint8_t hopper_idx_frequency; + bool is_database_loaded; + SubGhzHopperState hopper_state; + + SubGhzTxRxState txrx_state; + SubGhzSpeakerState speaker_state; + + SubGhzTxRxNeedSaveCallback need_save_callback; + void* need_save_context; + + bool debug_pin_state; +}; \ No newline at end of file diff --git a/applications/external/subghz_remote_new/icons/DolphinNice_96x59.png b/applications/external/subghz_remote_new/icons/DolphinNice_96x59.png new file mode 100644 index 0000000000000000000000000000000000000000..a299d3630239b4486e249cc501872bed5996df3b GIT binary patch literal 2459 zcmbVO3s4i+8V(M(gEFORwSrA`4O0uPn|M|5y* zB*aMDxC&7(gP9JN;POOi-9khrC>Z9YJs2U!LnVcQEEC0fDtKo&ILlzb30%M}3J^;~ zv7RzcsilOs4Mq@tD*&R;!LMSk2A~{(`HK9|hQBqEX)3sQr9Je6SZU*F-^fD-p+~Hs; zHLkO%v?>ZoxEv+F#whudr%615FkA0DYR0tMEo}3OOY#xecLWe>xV?u5KtSmC^ z7)Fmj6gjfKstiEV-*Cxbbb+&rRWuI_rBJ)ybs_f1Rn&f2>q3pYwI^|J(hdn{j{0EZIm_F zpIyIWLsRUgOItR-dUbVd|6Zo=_BU_Tj4|{{jxO#=JH4o8er(5{!nZD_j4}MH&zh~9 zVLC~y(0-D6GO0ghZD8BYzP?o{>22~lT6^d@X{SwQ8vrNY-PPIMajIwC)`s14Ep72@ zeq7YOzM`?U{+W)ocXBr`eSOcpk?Rxc=ou5&)fWW|pD};-Z0mvk9}=&`Rb&y<77W~a z(>6YM;6Y5aIU~JKZ}mQZynKHiSTQ#Bczn@&jTiN^?vPJ(jhm7cXLx0oum5P$`TceG zU+wR;OO^)8CVlnM)5p$CO&e94KJt>HccCaHGusmW_b`T6m| z-R6V6Db1pErTot?^d22ojm+2>_)FbD`_+WbDGMx9f@hO27maS2`csiV(D&Fs`PS2& zvrq18du_&zXID(!KIxsU$)iuTYuZ?zmYiP&n&i@Be{IdbS-jA2c0QAlu5NXQv_0K< z3Hvs4eeu6B7yD&CNT~gIkMV&UkRU=V!iQ(+_(O&u^ah$+s{_yn(yBYeD40HeU{xGsIT6W Zfq!wOp!QCbE6;07#-3sX@sAxkg$U?hnu$6%_P+PX_Jv(ud zLf1xG|CwUz?7R1Up5OC4zxVgNce*W&4YheW_vK(1mglK+H=%$1JZE+m`hA@F<1zI2 zyA8fptqH{ONK}=TAjGw<2*hDRkufZBKGgVD-U({Lf_l{mhyV1gGrhn5dOvmG&rb;X|2#O* z`;Gdu`y8=lFC6>o;MdlzEhu;(gUPC_z|AEGi;B+`t?Ze5z3-kKC+@xe!rsi0?9s|K zy?-daKNrL9+N8K#jUJb4ydqS`GmmU@)cv;7aPpz%>TUZsFY*}}-;x*iZ59ty6_jpT zvujoMQ}z8jJ+AG;!%Gj}Yq-_gD;(ypTplW&z40q}pQ&N1scCq0d(~q_cR%sbwf8Sv zdVdlA`l;oI1plLZ-jYiT3faL`zr6A#=Lo=7=AJsu{N?^-b1q)%coKW)>T~u}qi^rn z-7>H`clPEJwEVR7TGqAGdqR;5OY#pr*E?^={1s1Y&f(g=vM=|qHywW9AEyugs9|9K z_qUv^T38l3y>(BG-D_BB`RVoV^}JI09`V|mBd`AW<~wBWyCXky1n0|1Nlg+*V)QGN;EdcVFdq|MubW(V_Tn9{lz<&(!Cf?0&8A zl@E$Ck9Ky~46J|Y$whnDXUy8sU3Tos>?t>Un9|+}sNpj`p?cz$4F;W6I^yu1td=)j zwphHBH{ybAO5KJiY~Ik|6F0PrHpy5~o?}l42p|MCfG0x1a7;)zj7eMpo$JG-5l@?` zHXBJXB*PHMf{1m6HIN{}u@W63h2e%VF{(r~MGfORCh)5rn!{*B^Z0mvp@`R;h7ZTa zSU`M`2@oM^6GetXP{HeN+v@{V%k5_5e+8G zkwg*(VF;PVP*i$K$XbuLG3}vK5Kuyqq!%K4ie;ot)zny<8cCZ^NiaQ~ENpU0nj%lI zJjF+!xy>BKy>oC09YBCl_0@MKq5HSOc8#H zHxrPt@G@uPXxUw}=@F^kKtO1=<+RE`fZLx72 zM^h}%PZ&K2qcJ389h0U^tT{O|!J$hHs!^{hL5Gn|PU-6=pgIxrK<@yAog7DH3a%&w z8g!!r!BMD#C>udrd^9VVErOXZqga7TC7!lcqdrv)I*fX4xSm29%!}Gu0vbreA!k;g z%|4nF%vOQs$|!0w97;_$K_%JJIG$`y z0f?!B#blXMGE;<>npEzfp3l7GX_S~MYjF^T&H&=qVRY(yC*C;TeK^CKEcntEB`m4& z*s`e!#M_|0il0b3`57vUflm0by2LgR4nVX&k8KG5wO*Mw+x#3L%ravoDAo)K9*8VK z`z@R#$`oXol=A*h>SY-g(0){rAj zX|i`eX-Qc`CULv;$ClJi>UW`W?b^xP)oq_>=<%(|iFP_&{;^5&uL6OoA}L2u$;}G@ zRN$B(Zj5Yq}83M;=f=r9w8MiVD2l{4`U z0fy0oX&k*FI5pSMi{36|`Ri-l*r@*9d2H`fXk<>LZgmX9OeOkpSK|4KPBfUUdA!xx z?`7r}mf + +typedef enum { + SubRemSceneEditLabelStateTextInput, + SubRemSceneEditLabelStateWidget, +} SubRemSceneEditLabelState; + +void subrem_scene_edit_label_text_input_callback(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event( + app->view_dispatcher, SubRemCustomEventSceneEditLabelInputDone); +} + +void subrem_scene_edit_label_widget_callback(GuiButtonType result, InputType type, void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + if((result == GuiButtonTypeCenter) && (type == InputTypeShort)) { + view_dispatcher_send_custom_event( + app->view_dispatcher, SubRemCustomEventSceneEditLabelWidgetAcces); + } else if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) { + view_dispatcher_send_custom_event( + app->view_dispatcher, SubRemCustomEventSceneEditLabelWidgetBack); + } +} + +void subrem_scene_edit_label_on_enter(void* context) { + SubGhzRemoteApp* app = context; + + SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub]; + + FuriString* temp_str = furi_string_alloc(); + + if(furi_string_empty(sub_preset->label)) { + if(furi_string_empty(sub_preset->file_path)) { + path_extract_filename(sub_preset->file_path, temp_str, true); + strcpy(app->file_name_tmp, furi_string_get_cstr(temp_str)); + } else { + strcpy(app->file_name_tmp, ""); + } + } else { + strcpy(app->file_name_tmp, furi_string_get_cstr(sub_preset->label)); + } + + TextInput* text_input = app->text_input; + text_input_set_header_text(text_input, "Label name"); + text_input_set_result_callback( + text_input, + subrem_scene_edit_label_text_input_callback, + app, + app->file_name_tmp, + 25, + false); + + text_input_set_minimum_length(app->text_input, 0); + + widget_add_string_element( + app->widget, 63, 12, AlignCenter, AlignCenter, FontPrimary, "Empty Label Name"); + widget_add_string_element( + app->widget, 63, 32, AlignCenter, AlignCenter, FontSecondary, "Continue?"); + + widget_add_button_element( + app->widget, GuiButtonTypeCenter, "Ok", subrem_scene_edit_label_widget_callback, app); + widget_add_button_element( + app->widget, GuiButtonTypeLeft, "Back", subrem_scene_edit_label_widget_callback, app); + + scene_manager_set_scene_state( + app->scene_manager, SubRemSceneEditLabel, SubRemSceneEditLabelStateTextInput); + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDTextInput); + + furi_string_free(temp_str); +} + +bool subrem_scene_edit_label_on_event(void* context, SceneManagerEvent event) { + SubGhzRemoteApp* app = context; + + FuriString* label = app->map_preset->subs_preset[app->chusen_sub]->label; + + if(event.type == SceneManagerEventTypeBack) { + if(scene_manager_get_scene_state(app->scene_manager, SubRemSceneEditLabel) == + SubRemSceneEditLabelStateWidget) { + scene_manager_set_scene_state( + app->scene_manager, SubRemSceneEditLabel, SubRemSceneEditLabelStateTextInput); + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDTextInput); + return true; + } else if( + scene_manager_get_scene_state(app->scene_manager, SubRemSceneEditLabel) == + SubRemSceneEditLabelStateTextInput) { + scene_manager_previous_scene(app->scene_manager); + return true; + } + + scene_manager_previous_scene(app->scene_manager); + return true; + } else if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubRemCustomEventSceneEditLabelInputDone) { + if(strcmp(app->file_name_tmp, "") == 0) { + scene_manager_set_scene_state( + app->scene_manager, SubRemSceneEditLabel, SubRemSceneEditLabelStateWidget); + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDWidget); + + } else { + furi_string_set(label, app->file_name_tmp); + app->map_not_saved = true; + scene_manager_previous_scene(app->scene_manager); + } + return true; + } else if(event.event == SubRemCustomEventSceneEditLabelWidgetAcces) { + furi_string_set(label, app->file_name_tmp); + app->map_not_saved = true; + scene_manager_previous_scene(app->scene_manager); + + return true; + } else if(event.event == SubRemCustomEventSceneEditLabelWidgetBack) { + scene_manager_set_scene_state( + app->scene_manager, SubRemSceneEditLabel, SubRemSceneEditLabelStateTextInput); + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDTextInput); + + return true; + } + } + return false; +} + +void subrem_scene_edit_label_on_exit(void* context) { + SubGhzRemoteApp* app = context; + + // Clear view + text_input_reset(app->text_input); + widget_reset(app->widget); +} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_edit_menu.c b/applications/external/subghz_remote_new/scenes/subrem_scene_edit_menu.c new file mode 100644 index 0000000000..a8882009a8 --- /dev/null +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_edit_menu.c @@ -0,0 +1,123 @@ +#include "../subghz_remote_app_i.h" + +void subrem_scene_edit_menu_callback(SubRemCustomEvent event, void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, event); +} + +void subrem_scene_edit_menu_widget_callback(GuiButtonType result, InputType type, void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + if((result == GuiButtonTypeRight) && (type == InputTypeShort)) { + app->map_not_saved = false; + view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventViewEditMenuBack); + } else if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) { + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDEditMenu); + } +} + +static uint8_t subrem_scene_edit_menu_state_to_index(SubRemEditMenuState event_id) { + uint8_t ret = 0; + + if(event_id == SubRemEditMenuStateUP) { + ret = SubRemSubKeyNameUp; + } else if(event_id == SubRemEditMenuStateDOWN) { + ret = SubRemSubKeyNameDown; + } else if(event_id == SubRemEditMenuStateLEFT) { + ret = SubRemSubKeyNameLeft; + } else if(event_id == SubRemEditMenuStateRIGHT) { + ret = SubRemSubKeyNameRight; + } else if(event_id == SubRemEditMenuStateOK) { + ret = SubRemSubKeyNameOk; + } + + return ret; +} + +static void subrem_scene_edit_menu_update_data(SubGhzRemoteApp* app) { + furi_assert(app); + uint8_t index = subrem_scene_edit_menu_state_to_index( + scene_manager_get_scene_state(app->scene_manager, SubRemSceneEditMenu)); + + subrem_view_edit_menu_add_data_to_show( + app->subrem_edit_menu, + index, + app->map_preset->subs_preset[index]->label, + app->map_preset->subs_preset[index]->file_path, + app->map_preset->subs_preset[index]->load_state); +} + +void subrem_scene_edit_menu_on_enter(void* context) { + SubGhzRemoteApp* app = context; + + subrem_view_edit_menu_set_callback( + app->subrem_edit_menu, subrem_scene_edit_menu_callback, app); + + subrem_scene_edit_menu_update_data(app); + + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDEditMenu); + + Widget* widget = app->widget; + + widget_add_string_element( + widget, 63, 12, AlignCenter, AlignBottom, FontPrimary, "Changes are not saved"); + widget_add_string_element( + widget, 63, 32, AlignCenter, AlignBottom, FontPrimary, "do you want to exit?"); + + widget_add_button_element( + widget, GuiButtonTypeRight, "Yes", subrem_scene_edit_menu_widget_callback, app); + widget_add_button_element( + widget, GuiButtonTypeLeft, "No", subrem_scene_edit_menu_widget_callback, app); +} + +bool subrem_scene_edit_menu_on_event(void* context, SceneManagerEvent event) { + SubGhzRemoteApp* app = context; + + if(event.type == SceneManagerEventTypeBack) { + // Catch widget backEvent + return true; + } + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubRemCustomEventViewEditMenuBack) { + if(app->map_not_saved) { + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDWidget); + } else if(!scene_manager_search_and_switch_to_previous_scene( + app->scene_manager, SubRemSceneStart)) { + scene_manager_stop(app->scene_manager); + view_dispatcher_stop(app->view_dispatcher); + } + + return true; + } else if( + event.event == SubRemCustomEventViewEditMenuUP || + event.event == SubRemCustomEventViewEditMenuDOWN) { + scene_manager_set_scene_state( + app->scene_manager, + SubRemSceneEditMenu, + subrem_view_edit_menu_get_index(app->subrem_edit_menu)); + subrem_scene_edit_menu_update_data(app); + + return true; + } else if(event.event == SubRemCustomEventViewEditMenuEdit) { + app->chusen_sub = subrem_view_edit_menu_get_index(app->subrem_edit_menu); + scene_manager_set_scene_state( + app->scene_manager, SubRemSceneEditSubMenu, EditSubmenuIndexEditLabel); + scene_manager_next_scene(app->scene_manager, SubRemSceneEditSubMenu); + + return true; + } else if(event.event == SubRemCustomEventViewEditMenuSave) { + scene_manager_next_scene(app->scene_manager, SubRemSceneEditPreview); + + return true; + } + } + + return false; +} + +void subrem_scene_edit_menu_on_exit(void* context) { + SubGhzRemoteApp* app = context; + widget_reset(app->widget); +} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_edit_preview.c b/applications/external/subghz_remote_new/scenes/subrem_scene_edit_preview.c new file mode 100644 index 0000000000..98a423202e --- /dev/null +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_edit_preview.c @@ -0,0 +1,74 @@ +#include "../subghz_remote_app_i.h" +#include "../views/remote.h" + +#define TAG "SubRemScenRemote" + +void subghz_scene_edit_preview_save_popup_callback(void* context) { + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event( + app->view_dispatcher, SubRemCustomEventSceneEditPreviewSaved); +} + +void subrem_scene_edit_preview_callback(SubRemCustomEvent event, void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, event); +} + +void subrem_scene_edit_preview_on_enter(void* context) { + SubGhzRemoteApp* app = context; + + // Setup view + Popup* popup = app->popup; + popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59); + popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom); + popup_set_timeout(popup, 1500); + popup_set_context(popup, app); + popup_set_callback(popup, subghz_scene_edit_preview_save_popup_callback); + popup_enable_timeout(popup); + + subrem_view_remote_update_data_labels(app->subrem_remote_view, app->map_preset->subs_preset); + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateOFF, 0); + + subrem_view_remote_set_callback( + app->subrem_remote_view, subrem_scene_edit_preview_callback, app); + + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDRemote); +} + +bool subrem_scene_edit_preview_on_event(void* context, SceneManagerEvent event) { + SubGhzRemoteApp* app = context; + + if(event.type == SceneManagerEventTypeBack || + (event.type == SceneManagerEventTypeCustom && + (event.event == SubRemCustomEventViewRemoteStartLEFT || + event.event == SubRemCustomEventViewRemoteForcedStop))) { + scene_manager_previous_scene(app->scene_manager); + return true; + } else if( + event.type == SceneManagerEventTypeCustom && + (event.event == SubRemCustomEventViewRemoteStartRIGHT || + event.event == SubRemCustomEventViewRemoteStartOK)) { + if(subrem_save_map_to_file(app)) { + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDPopup); + app->map_not_saved = false; + return true; + } + // TODO error screen + return true; + } else if( + event.type == SceneManagerEventTypeCustom && + event.event == SubRemCustomEventSceneEditPreviewSaved) { + scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SubRemSceneEditMenu); + } + // } else if(event.type == SceneManagerEventTypeTick) { + // } + return false; +} + +void subrem_scene_edit_preview_on_exit(void* context) { + SubGhzRemoteApp* app = context; + + subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle, 0); + popup_reset(app->popup); +} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_edit_submenu.c b/applications/external/subghz_remote_new/scenes/subrem_scene_edit_submenu.c new file mode 100644 index 0000000000..447beb96d9 --- /dev/null +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_edit_submenu.c @@ -0,0 +1,54 @@ +#include "../subghz_remote_app_i.h" +#include "../helpers/subrem_custom_event.h" + +void subrem_scene_edit_submenu_text_input_callback(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventSceneEditsubmenu); +} + +void subrem_scene_edit_submenu_callback(void* context, uint32_t index) { + furi_assert(context); + SubGhzRemoteApp* app = context; + + view_dispatcher_send_custom_event(app->view_dispatcher, index); +} + +void subrem_scene_edit_submenu_on_enter(void* context) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + Submenu* submenu = app->submenu; + submenu_add_item( + submenu, "Edit Label", EditSubmenuIndexEditLabel, subrem_scene_edit_submenu_callback, app); + submenu_add_item( + submenu, "Edit File", EditSubmenuIndexEditFile, subrem_scene_edit_submenu_callback, app); + + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDSubmenu); +} + +bool subrem_scene_edit_submenu_on_event(void* context, SceneManagerEvent event) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == EditSubmenuIndexEditLabel) { + scene_manager_next_scene(app->scene_manager, SubRemSceneEditLabel); + consumed = true; + } else if(event.event == EditSubmenuIndexEditFile) { + scene_manager_next_scene(app->scene_manager, SubRemSceneOpenSubFile); + consumed = true; + } + } + + return consumed; +} + +void subrem_scene_edit_submenu_on_exit(void* context) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + submenu_reset(app->submenu); +} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_enter_new_name.c b/applications/external/subghz_remote_new/scenes/subrem_scene_enter_new_name.c new file mode 100644 index 0000000000..d33e070af5 --- /dev/null +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_enter_new_name.c @@ -0,0 +1,71 @@ +#include "../subghz_remote_app_i.h" +#include "../helpers/subrem_custom_event.h" + +#include + +void subrem_scene_enter_new_name_text_input_callback(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventSceneNewName); +} + +void subrem_scene_enter_new_name_on_enter(void* context) { + SubGhzRemoteApp* app = context; + + // Setup view + TextInput* text_input = app->text_input; + bool dev_name_empty = false; + + strncpy(app->file_name_tmp, "subrem_", SUBREM_MAX_LEN_NAME); + text_input_set_header_text(text_input, "Map file Name"); + text_input_set_result_callback( + text_input, + subrem_scene_enter_new_name_text_input_callback, + app, + app->file_name_tmp, + 25, + dev_name_empty); + + ValidatorIsFile* validator_is_file = validator_is_file_alloc_init( + furi_string_get_cstr(app->file_path), SUBREM_APP_EXTENSION, ""); + text_input_set_validator(text_input, validator_is_file_callback, validator_is_file); + + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDTextInput); +} + +bool subrem_scene_enter_new_name_on_event(void* context, SceneManagerEvent event) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubRemCustomEventSceneNewName) { + if(strcmp(app->file_name_tmp, "") != 0) { + furi_string_set(app->file_path, SUBREM_APP_FOLDER); + furi_string_cat_printf( + app->file_path, "/%s%s", app->file_name_tmp, SUBREM_APP_EXTENSION); + + subrem_map_preset_reset(app->map_preset); + scene_manager_next_scene(app->scene_manager, SubRemSceneEditMenu); + } else { //error + } + consumed = true; + } + } + + return consumed; +} + +void subrem_scene_enter_new_name_on_exit(void* context) { + furi_assert(context); + + SubGhzRemoteApp* app = context; + submenu_reset(app->submenu); + + // Clear validator & view + void* validator_context = text_input_get_validator_callback_context(app->text_input); + text_input_set_validator(app->text_input, NULL, NULL); + validator_is_file_free(validator_context); + text_input_reset(app->text_input); +} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_open_map_file.c b/applications/external/subghz_remote_new/scenes/subrem_scene_open_map_file.c new file mode 100644 index 0000000000..77f2d2d561 --- /dev/null +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_open_map_file.c @@ -0,0 +1,29 @@ +#include "../subghz_remote_app_i.h" + +void subrem_scene_open_map_file_on_enter(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + + SubRemLoadMapState load_state = subrem_load_from_file(app); + uint32_t start_scene_state = + scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart); + + // TODO if optimization + + if(load_state == SubRemLoadMapStateBack) { + scene_manager_previous_scene(app->scene_manager); + } else if(start_scene_state == SubmenuIndexSubRemEditMapFile) { + scene_manager_set_scene_state(app->scene_manager, SubRemSceneEditMenu, SubRemSubKeyNameUp); + scene_manager_next_scene(app->scene_manager, SubRemSceneEditMenu); + } +} + +bool subrem_scene_open_map_file_on_event(void* context, SceneManagerEvent event) { + UNUSED(context); + UNUSED(event); + return false; +} + +void subrem_scene_open_map_file_on_exit(void* context) { + UNUSED(context); +} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_open_sub_file.c b/applications/external/subghz_remote_new/scenes/subrem_scene_open_sub_file.c new file mode 100644 index 0000000000..75dc216704 --- /dev/null +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_open_sub_file.c @@ -0,0 +1,116 @@ +#include "../subghz_remote_app_i.h" + +void subrem_scene_open_sub_file_error_popup_callback(void* context) { + SubGhzRemoteApp* app = context; + view_dispatcher_send_custom_event( + app->view_dispatcher, SubRemCustomEventSceneEditOpenSubErrorPopup); +} + +SubRemLoadSubState subrem_scene_open_sub_file_dialog(SubGhzRemoteApp* app) { + furi_assert(app); + + SubRemSubFilePreset* sub = app->map_preset->subs_preset[app->chusen_sub]; + + FuriString* temp_file_path = furi_string_alloc_set(sub->file_path); + + SubRemLoadSubState ret = SubRemLoadSubStateNotSet; + + DialogsFileBrowserOptions browser_options; + + dialog_file_browser_set_basic_options(&browser_options, SUBGHZ_APP_EXTENSION, &I_sub1_10px); + browser_options.base_path = SUBGHZ_APP_FOLDER; + + // Input events and views are managed by file_select + if(!dialog_file_browser_show( + app->dialogs, + temp_file_path, + furi_string_empty(temp_file_path) ? NULL : temp_file_path, + &browser_options)) { + } else { + // Check sub file + SubRemSubFilePreset* sub_candidate = subrem_sub_file_preset_alloc(); + furi_string_set(sub_candidate->label, sub->label); + furi_string_set(sub_candidate->file_path, temp_file_path); + + Storage* storage = furi_record_open(RECORD_STORAGE); + FlipperFormat* fff_file = flipper_format_file_alloc(storage); + + if(flipper_format_file_open_existing( + fff_file, furi_string_get_cstr(sub_candidate->file_path))) { + ret = subrem_sub_preset_load(sub_candidate, app->txrx, fff_file); + } + + flipper_format_file_close(fff_file); + flipper_format_free(fff_file); + furi_record_close(RECORD_STORAGE); + + if(ret == SubRemLoadSubStateOK) { + subrem_sub_file_preset_free(app->map_preset->subs_preset[app->chusen_sub]); + app->map_preset->subs_preset[app->chusen_sub] = sub_candidate; + app->map_not_saved = true; + } else { + subrem_sub_file_preset_free(sub_candidate); + } + } + + furi_string_free(temp_file_path); + + return ret; +} + +void subrem_scene_open_sub_file_on_enter(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + + SubRemLoadSubState load_state = subrem_scene_open_sub_file_dialog(app); + + Popup* popup = app->popup; + // popup_set_icon(); + popup_set_header(popup, "ERROR", 63, 16, AlignCenter, AlignBottom); + popup_set_timeout(popup, 1500); + popup_set_context(popup, app); + popup_set_callback(popup, subrem_scene_open_sub_file_error_popup_callback); + popup_enable_timeout(popup); + + if(load_state == SubRemLoadSubStateOK) { + scene_manager_previous_scene(app->scene_manager); + } else if(load_state == SubRemLoadSubStateNotSet) { + scene_manager_previous_scene(app->scene_manager); + } else { + switch(load_state) { + case SubRemLoadSubStateErrorFreq: + + popup_set_text(popup, "Bad frequency", 63, 30, AlignCenter, AlignBottom); + break; + case SubRemLoadSubStateErrorMod: + + popup_set_text(popup, "Bad modulation", 63, 30, AlignCenter, AlignBottom); + break; + case SubRemLoadSubStateErrorProtocol: + + popup_set_text(popup, "Unsupported protocol", 63, 30, AlignCenter, AlignBottom); + break; + + default: + break; + } + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDPopup); + } +} + +bool subrem_scene_open_sub_file_on_event(void* context, SceneManagerEvent event) { + SubGhzRemoteApp* app = context; + + if(event.type == SceneManagerEventTypeCustom && + event.event == SubRemCustomEventSceneEditOpenSubErrorPopup) { + scene_manager_previous_scene(app->scene_manager); + return true; + } + return false; +} + +void subrem_scene_open_sub_file_on_exit(void* context) { + SubGhzRemoteApp* app = context; + + popup_reset(app->popup); +} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c deleted file mode 100644 index 8e6d9d0ddc..0000000000 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "../subghz_remote_app_i.h" - -void subrem_scene_openmapfile_on_enter(void* context) { - SubGhzRemoteApp* app = context; - SubRemLoadMapState load_state = subrem_load_from_file(app); - - if(load_state == SubRemLoadMapStateError) { -#ifdef SUBREM_LIGHT - dialog_message_show_storage_error(app->dialogs, "Can't load\nMap file"); -#else - DialogMessage* message = dialog_message_alloc(); - - dialog_message_set_header(message, "Map File Error", 64, 8, AlignCenter, AlignCenter); - dialog_message_set_text(message, "Can't load\nMap file", 64, 32, AlignCenter, AlignCenter); - dialog_message_set_buttons(message, "Back", NULL, NULL); - dialog_message_show(app->dialogs, message); - - dialog_message_free(message); -#endif - } - if(load_state == SubRemLoadMapStateOK || load_state == SubRemLoadMapStateNotAllOK) { - } else { - // TODO: Map Preset Reset - if(!scene_manager_search_and_switch_to_previous_scene( - app->scene_manager, SubRemSceneStart)) { - scene_manager_stop(app->scene_manager); - view_dispatcher_stop(app->view_dispatcher); - } - } -} - -bool subrem_scene_openmapfile_on_event(void* context, SceneManagerEvent event) { - UNUSED(context); - UNUSED(event); - return false; -} - -void subrem_scene_openmapfile_on_exit(void* context) { - UNUSED(context); -} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c index fd2d61c480..e5a254111d 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c @@ -13,14 +13,18 @@ void subrem_scene_start_on_enter(void* context) { SubGhzRemoteApp* app = context; Submenu* submenu = app->submenu; -#if FURI_DEBUG submenu_add_item( submenu, - "Remote_Debug", - SubmenuIndexSubRemRemoteView, + "Edit Map File", + SubmenuIndexSubRemEditMapFile, + subrem_scene_start_submenu_callback, + app); + submenu_add_item( + submenu, + "New Map File", + SubmenuIndexSubRemNewMapFile, subrem_scene_start_submenu_callback, app); -#endif // submenu_add_item( // submenu, // "About", @@ -28,12 +32,10 @@ void subrem_scene_start_on_enter(void* context) { // subrem_scene_start_submenu_callback, // app); - // TODO: set scene state in subrem alloc - // submenu_set_selected_item( - // submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); - submenu_set_selected_item(submenu, 0); + submenu_set_selected_item( + submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); - view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewSubmenu); + view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDSubmenu); } bool subrem_scene_start_on_event(void* context, SceneManagerEvent event) { @@ -41,8 +43,19 @@ bool subrem_scene_start_on_event(void* context, SceneManagerEvent event) { SubGhzRemoteApp* app = context; bool consumed = false; - UNUSED(app); + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubmenuIndexSubRemEditMapFile) { + scene_manager_set_scene_state( + app->scene_manager, SubRemSceneStart, SubmenuIndexSubRemEditMapFile); + scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile); + consumed = true; + } else if(event.event == SubmenuIndexSubRemNewMapFile) { + scene_manager_set_scene_state( + app->scene_manager, SubRemSceneStart, SubmenuIndexSubRemNewMapFile); + scene_manager_next_scene(app->scene_manager, SubRemSceneEnterNewName); + consumed = true; + } // } else if(event.event == SubmenuIndexSubRemAbout) { // scene_manager_next_scene(app->scene_manager, SubRemSceneAbout); // consumed = true; diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_new/subghz_remote_app.c index b957fb8bcb..e026fe4dea 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app.c +++ b/applications/external/subghz_remote_new/subghz_remote_app.c @@ -1,7 +1,5 @@ #include "subghz_remote_app_i.h" -#include - static bool subghz_remote_app_custom_event_callback(void* context, uint32_t event) { furi_assert(context); SubGhzRemoteApp* app = context; @@ -23,6 +21,14 @@ static void subghz_remote_app_tick_event_callback(void* context) { SubGhzRemoteApp* subghz_remote_app_alloc() { SubGhzRemoteApp* app = malloc(sizeof(SubGhzRemoteApp)); + Storage* storage = furi_record_open(RECORD_STORAGE); + storage_common_migrate(storage, EXT_PATH("unirf"), SUBREM_APP_FOLDER); + + if(!storage_simply_mkdir(storage, SUBREM_APP_FOLDER)) { + //FURI_LOG_E(TAG, "Could not create folder %s", SUBREM_APP_FOLDER); + } + furi_record_close(RECORD_STORAGE); + // Enable power for External CC1101 if it is connected furi_hal_subghz_enable_ext_power(); // Auto switch to internal radio if external radio is not available @@ -62,11 +68,25 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { // SubMenu app->submenu = submenu_alloc(); view_dispatcher_add_view( - app->view_dispatcher, SubRemViewSubmenu, submenu_get_view(app->submenu)); + app->view_dispatcher, SubRemViewIDSubmenu, submenu_get_view(app->submenu)); - //Dialog + // Dialog app->dialogs = furi_record_open(RECORD_DIALOGS); + // TextInput + app->text_input = text_input_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, SubRemViewIDTextInput, text_input_get_view(app->text_input)); + + // Widget + app->widget = widget_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, SubRemViewIDWidget, widget_get_view(app->widget)); + + // Popup + app->popup = popup_alloc(); + view_dispatcher_add_view(app->view_dispatcher, SubRemViewIDPopup, popup_get_view(app->popup)); + // Remote view app->subrem_remote_view = subrem_view_remote_alloc(); view_dispatcher_add_view( @@ -74,34 +94,30 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { SubRemViewIDRemote, subrem_view_remote_get_view(app->subrem_remote_view)); + // Edit Menu view + app->subrem_edit_menu = subrem_view_edit_menu_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, + SubRemViewIDEditMenu, + subrem_view_edit_menu_get_view(app->subrem_edit_menu)); + + app->map_preset = malloc(sizeof(SubRemMapPreset)); for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - app->subs_preset[i] = subrem_sub_file_preset_alloc(); + app->map_preset->subs_preset[i] = subrem_sub_file_preset_alloc(); } - app->setting = subghz_setting_alloc(); - subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user")); - - app->environment = subghz_environment_alloc(); - - subghz_environment_load_keystore(app->environment, EXT_PATH("subghz/assets/keeloq_mfcodes")); - subghz_environment_load_keystore( - app->environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user")); - subghz_environment_set_came_atomo_rainbow_table_file_name( - app->environment, EXT_PATH("subghz/assets/came_atomo")); - subghz_environment_set_alutech_at_4n_rainbow_table_file_name( - app->environment, EXT_PATH("subghz/assets/alutech_at_4n")); - subghz_environment_set_nice_flor_s_rainbow_table_file_name( - app->environment, EXT_PATH("subghz/assets/nice_flor_s")); - subghz_environment_set_protocol_registry(app->environment, (void*)&subghz_protocol_registry); + app->txrx = subghz_txrx_alloc(); - app->receiver = subghz_receiver_alloc_init(app->environment); + subghz_txrx_set_need_save_callback(app->txrx, subrem_save_active_sub, app); - app->tx_running = false; + app->map_not_saved = false; #ifdef SUBREM_LIGHT scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile); #else scene_manager_next_scene(app->scene_manager, SubRemSceneStart); + scene_manager_set_scene_state( + app->scene_manager, SubRemSceneStart, SubmenuIndexSubRemEditMapFile); #endif return app; @@ -118,26 +134,41 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { furi_hal_subghz_init_radio_type(SubGhzRadioInternal); // Submenu - view_dispatcher_remove_view(app->view_dispatcher, SubRemViewSubmenu); + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDSubmenu); submenu_free(app->submenu); - //Dialog + // Dialog furi_record_close(RECORD_DIALOGS); + // TextInput + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDTextInput); + text_input_free(app->text_input); + + // Widget + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDWidget); + widget_free(app->widget); + + // Popup + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDPopup); + popup_free(app->popup); + // Remote view view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDRemote); subrem_view_remote_free(app->subrem_remote_view); + // Edit view + view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDEditMenu); + subrem_view_edit_menu_free(app->subrem_edit_menu); + scene_manager_free(app->scene_manager); view_dispatcher_free(app->view_dispatcher); - subghz_receiver_free(app->receiver); - subghz_environment_free(app->environment); - subghz_setting_free(app->setting); + subghz_txrx_free(app->txrx); for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - subrem_sub_file_preset_free(app->subs_preset[i]); + subrem_sub_file_preset_free(app->map_preset->subs_preset[i]); } + free(app->map_preset); // Notifications furi_record_close(RECORD_NOTIFICATION); diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index aa8983951b..1eb64541ff 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -2,12 +2,13 @@ #include #include -#include +#include "helpers/txrx/subghz_txrx.h" // #include // #include -#include +// #include +// #include #define TAG "SubGhzRemote" @@ -19,88 +20,73 @@ static const char* map_file_labels[SubRemSubKeyNameMaxCount][2] = { [SubRemSubKeyNameOk] = {"OK", "OKLABEL"}, }; -static bool - subrem_set_preset_data(SubGhzSetting* setting, FreqPreset* freq_preset, const char* preset) { - const char* preset_name = ""; - if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) { - preset_name = "AM270"; - } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) { - preset_name = "AM650"; - } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) { - preset_name = "FM238"; - } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) { - preset_name = "FM476"; - } else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) { - // preset_name = "CUSTOM"; - return false; - } else { - FURI_LOG_E(TAG, "Unknown preset"); - return false; - } - size_t preset_index = subghz_setting_get_inx_preset_by_name(setting, preset_name); - freq_preset->data = subghz_setting_get_preset_data(setting, preset_index); - return true; -} - -SubRemSubFilePreset* subrem_sub_file_preset_alloc() { - SubRemSubFilePreset* sub_preset = malloc(sizeof(SubRemSubFilePreset)); - - sub_preset->fff_data = flipper_format_string_alloc(); - sub_preset->file_path = furi_string_alloc(); - sub_preset->protocaol_name = furi_string_alloc(); - sub_preset->label = furi_string_alloc_set_str("N/A"); - - sub_preset->type = SubGhzProtocolTypeUnknown; - sub_preset->load_state = SubRemLoadSubStateNotSet; +void subrem_map_preset_reset(SubRemMapPreset* map_preset) { + furi_assert(map_preset); - return sub_preset; + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + subrem_sub_file_preset_reset(map_preset->subs_preset[i]); + } } -void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset) { - furi_assert(sub_preset); +static SubRemLoadMapState subrem_map_preset_check( + SubRemMapPreset* map_preset, + SubGhzTxRx* txrx, + FlipperFormat* fff_data_file) { + furi_assert(map_preset); + furi_assert(txrx); - furi_string_free(sub_preset->label); - furi_string_free(sub_preset->protocaol_name); - furi_string_free(sub_preset->file_path); - flipper_format_free(sub_preset->fff_data); + bool all_loaded = true; + SubRemLoadMapState ret = SubRemLoadMapStateErrorBrokenFile; - free(sub_preset); -} + SubRemLoadSubState sub_loadig_state; + SubRemSubFilePreset* sub_preset; -static void subrem_sub_file_preset_reset(SubRemSubFilePreset* sub_preset) { - furi_assert(sub_preset); + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + sub_preset = map_preset->subs_preset[i]; - furi_string_set_str(sub_preset->label, "N/A"); - furi_string_reset(sub_preset->protocaol_name); - furi_string_reset(sub_preset->file_path); + sub_loadig_state = SubRemLoadSubStateErrorNoFile; - Stream* fff_data_stream = flipper_format_get_raw_stream(sub_preset->fff_data); - stream_clean(fff_data_stream); + if(furi_string_empty(sub_preset->file_path)) { + // FURI_LOG_I(TAG, "Empty file path"); + } else if(!flipper_format_file_open_existing( + fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { + sub_preset->load_state = SubRemLoadSubStateErrorNoFile; + FURI_LOG_W(TAG, "Error open file %s", furi_string_get_cstr(sub_preset->file_path)); + } else { + sub_loadig_state = subrem_sub_preset_load(sub_preset, txrx, fff_data_file); + } - sub_preset->type = SubGhzProtocolTypeUnknown; - sub_preset->load_state = SubRemLoadSubStateNotSet; -} + if(sub_loadig_state != SubRemLoadSubStateOK) { + all_loaded = false; + } else { + ret = SubRemLoadMapStateNotAllOK; + } -void subrem_map_preset_reset(SubGhzRemoteApp* app) { - furi_assert(app); + if(ret != SubRemLoadMapStateErrorBrokenFile && all_loaded) { + ret = SubRemLoadMapStateOK; + } - for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - subrem_sub_file_preset_reset(app->subs_preset[i]); + flipper_format_file_close(fff_data_file); } + + return ret; } -static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { - furi_assert(app); +static bool subrem_map_preset_load(SubRemMapPreset* map_preset, FlipperFormat* fff_data_file) { + furi_assert(map_preset); bool ret = false; SubRemSubFilePreset* sub_preset; for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - sub_preset = app->subs_preset[i]; + sub_preset = map_preset->subs_preset[i]; if(!flipper_format_read_string( fff_data_file, map_file_labels[i][0], sub_preset->file_path)) { #if FURI_DEBUG FURI_LOG_W(TAG, "No file patch for %s", map_file_labels[i][0]); #endif sub_preset->type = SubGhzProtocolTypeUnknown; + } else if(!path_contains_only_ascii(furi_string_get_cstr(sub_preset->file_path))) { + FURI_LOG_E(TAG, "Incorrect characters in [%s] file path", map_file_labels[i][0]); + sub_preset->type = SubGhzProtocolTypeUnknown; } else if(!flipper_format_rewind(fff_data_file)) { // Rewind error } else if(!flipper_format_read_string( @@ -108,8 +94,11 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data #if FURI_DEBUG FURI_LOG_W(TAG, "No Label for %s", map_file_labels[i][0]); #endif - path_extract_filename(sub_preset->file_path, sub_preset->label, true); + ret = true; } else { + ret = true; + } + if(ret) { // Preload seccesful FURI_LOG_I( TAG, @@ -117,192 +106,11 @@ static bool subrem_map_preset_load(SubGhzRemoteApp* app, FlipperFormat* fff_data map_file_labels[i][0], furi_string_get_cstr(sub_preset->label), furi_string_get_cstr(sub_preset->file_path)); - ret = true; sub_preset->load_state = SubRemLoadSubStatePreloaded; } - flipper_format_rewind(fff_data_file); - } - return ret; -} - -bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev_file_name) { - furi_assert(flipper_format); - furi_assert(dev_file_name); - - Storage* storage = furi_record_open(RECORD_STORAGE); - Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); - - bool saved = false; - uint32_t repeat = 200; - FuriString* file_dir = furi_string_alloc(); - - path_extract_dirname(dev_file_name, file_dir); - do { - // removing additional fields - flipper_format_delete_key(flipper_format, "Repeat"); - // flipper_format_delete_key(flipper_format, "Manufacture"); - - if(!storage_simply_remove(storage, dev_file_name)) { - break; - } - //ToDo check Write - stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); - stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS); - - if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { - FURI_LOG_E(TAG, "Unable Repeat"); - break; - } - - saved = true; - } while(0); - - furi_string_free(file_dir); - furi_record_close(RECORD_STORAGE); - return saved; -} - -static SubRemLoadMapState - subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { - furi_assert(app); - FuriString* temp_str = furi_string_alloc(); - uint32_t temp_data32; - bool all_loaded = true; - SubRemLoadMapState ret = SubRemLoadMapStateErrorBrokenFile; - SubRemLoadSubState sub_preset_loaded; - SubRemSubFilePreset* sub_preset; - uint32_t repeat = 200; - for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { - sub_preset = app->subs_preset[i]; - if(furi_string_empty(sub_preset->file_path)) { - // FURI_LOG_I(TAG, "Empty file path"); - continue; - } - - sub_preset_loaded = SubRemLoadSubStateErrorNoFile; - - repeat = 200; - do { - if(!flipper_format_file_open_existing( - fff_data_file, furi_string_get_cstr(sub_preset->file_path))) { - FURI_LOG_W(TAG, "Error open file %s", furi_string_get_cstr(sub_preset->file_path)); - break; - } - - if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) { - FURI_LOG_E(TAG, "Missing or incorrect header"); - break; - } - - if(((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) || - (!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) && - temp_data32 == SUBGHZ_KEY_FILE_VERSION) { - } else { - FURI_LOG_E(TAG, "Type or version mismatch"); - break; - } - - //Load frequency - sub_preset_loaded = SubRemLoadSubStateErrorFreq; - if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { - FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); - sub_preset->freq_preset.frequency = - subghz_setting_get_default_frequency(app->setting); - } else if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { - FURI_LOG_E(TAG, "This frequency can only be used for RX"); - break; - } else { - sub_preset->freq_preset.frequency = temp_data32; - } - - //Load preset - sub_preset_loaded = SubRemLoadSubStateErrorMod; - if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { - FURI_LOG_E(TAG, "Missing Preset"); - break; - } - - if(!subrem_set_preset_data( - app->setting, &sub_preset->freq_preset, furi_string_get_cstr(temp_str))) { - FURI_LOG_E(TAG, "Cannot load preset."); - break; - } - - //Load protocol - sub_preset_loaded = SubRemLoadSubStateErrorProtocol; - if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) { - FURI_LOG_E(TAG, "Missing Protocol"); - break; - } - - FlipperFormat* fff_data = sub_preset->fff_data; - if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) { - //if RAW - subghz_protocol_raw_gen_fff_data( - fff_data, furi_string_get_cstr(sub_preset->file_path)); - } else { - stream_copy_full( - flipper_format_get_raw_stream(fff_data_file), - flipper_format_get_raw_stream(fff_data)); - } - - const SubGhzProtocolRegistry* protocol_registry_items = - subghz_environment_get_protocol_registry(app->environment); - - const SubGhzProtocol* protocol = subghz_protocol_registry_get_by_name( - protocol_registry_items, furi_string_get_cstr(temp_str)); - - if(!protocol) { - FURI_LOG_E(TAG, "Protocol not found"); - break; - } else if(protocol->flag & SubGhzProtocolFlag_Send) { - if((protocol->type == SubGhzProtocolTypeStatic) || - (protocol->type == SubGhzProtocolTypeDynamic) || - // (protocol->type == SubGhzProtocolTypeBinRAW) || // TODO: BINRAW - (protocol->type == SubGhzProtocolTypeRAW)) { - sub_preset->type = protocol->type; - } else { - FURI_LOG_E(TAG, "Unsuported Protocol"); - break; - } - - furi_string_set(sub_preset->protocaol_name, temp_str); - } else { - FURI_LOG_E(TAG, "Protocol does not support transmission"); - } - - if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &repeat, 1)) { - FURI_LOG_E(TAG, "Unable Repeat"); - break; - } - - sub_preset_loaded = SubRemLoadSubStateOK; - ret = SubRemLoadMapStateNotAllOK; - -#if FURI_DEBUG - FURI_LOG_I(TAG, "%-16s - protocol Loaded", furi_string_get_cstr(sub_preset->label)); -#endif - } while(false); - - // TODO: - // Load file state logic - // Label depending on the state - // Move to remote scene - - if(sub_preset_loaded != SubRemLoadSubStateOK) { - furi_string_set_str(sub_preset->label, "N/A"); - all_loaded = false; - } - - if(ret != SubRemLoadMapStateErrorBrokenFile && all_loaded) { - ret = SubRemLoadMapStateOK; - } - - flipper_format_file_close(fff_data_file); + flipper_format_rewind(fff_data_file); } - furi_string_free(temp_str); - return ret; } @@ -318,19 +126,19 @@ SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_p #if FURI_DEBUG FURI_LOG_I(TAG, "Open Map File.."); #endif - subrem_map_preset_reset(app); + subrem_map_preset_reset(app->map_preset); if(!flipper_format_file_open_existing(fff_data_file, file_path)) { FURI_LOG_E(TAG, "Could not open MAP file %s", file_path); ret = SubRemLoadMapStateErrorOpenError; } else { - if(!subrem_map_preset_load(app, fff_data_file)) { + if(!subrem_map_preset_load(app->map_preset, fff_data_file)) { FURI_LOG_E(TAG, "Could no Sub file path in MAP file"); // ret = // error for popup } else if(!flipper_format_file_close(fff_data_file)) { ret = SubRemLoadMapStateErrorOpenError; } else { - ret = subrem_map_preset_check(app, fff_data_file); + ret = subrem_map_preset_check(app->map_preset, app->txrx, fff_data_file); } } @@ -349,6 +157,53 @@ SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_p return ret; } +bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* sub_file_name) { + furi_assert(flipper_format); + furi_assert(sub_file_name); + + Storage* storage = furi_record_open(RECORD_STORAGE); + Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format); + + bool saved = false; + uint32_t repeat = 200; + FuriString* file_dir = furi_string_alloc(); + + path_extract_dirname(sub_file_name, file_dir); + do { + // removing additional fields + flipper_format_delete_key(flipper_format, "Repeat"); + // flipper_format_delete_key(flipper_format, "Manufacture"); + + if(!storage_simply_remove(storage, sub_file_name)) { + break; + } + + //ToDo check Write + stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); + stream_save_to_file(flipper_format_stream, storage, sub_file_name, FSOM_CREATE_ALWAYS); + + if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) { + FURI_LOG_E(TAG, "Unable Repeat"); + break; + } + + saved = true; + } while(0); + + furi_string_free(file_dir); + furi_record_close(RECORD_STORAGE); + return saved; +} + +void subrem_save_active_sub(void* context) { + furi_assert(context); + SubGhzRemoteApp* app = context; + + SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub]; + subrem_save_protocol_to_file( + sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); +} + SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) { furi_assert(app); @@ -356,7 +211,7 @@ SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) { SubRemLoadMapState ret = SubRemLoadMapStateBack; DialogsFileBrowserOptions browser_options; - dialog_file_browser_set_basic_options(&browser_options, SUBREM_APP_EXTENSION, &I_sub1_10px); + dialog_file_browser_set_basic_options(&browser_options, SUBREM_APP_EXTENSION, &I_subrem_10px); browser_options.base_path = SUBREM_APP_FOLDER; // Input events and views are managed by file_select @@ -369,3 +224,47 @@ SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) { return ret; } + +bool subrem_save_map_to_file(SubGhzRemoteApp* app) { + furi_assert(app); + + const char* file_name = furi_string_get_cstr(app->file_path); + bool saved = false; + FlipperFormat* fff_data = flipper_format_string_alloc(); + + SubRemSubFilePreset* sub_preset; + + flipper_format_write_header_cstr( + fff_data, SUBREM_APP_APP_FILE_TYPE, SUBREM_APP_APP_FILE_VERSION); + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + sub_preset = app->map_preset->subs_preset[i]; + if(!furi_string_empty(sub_preset->file_path)) { + flipper_format_write_string(fff_data, map_file_labels[i][0], sub_preset->file_path); + } + } + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + sub_preset = app->map_preset->subs_preset[i]; + if(!furi_string_empty(sub_preset->file_path)) { + flipper_format_write_string(fff_data, map_file_labels[i][1], sub_preset->label); + } + } + + Storage* storage = furi_record_open(RECORD_STORAGE); + Stream* flipper_format_stream = flipper_format_get_raw_stream(fff_data); + + do { + if(!storage_simply_remove(storage, file_name)) { + break; + } + //ToDo check Write + stream_seek(flipper_format_stream, 0, StreamOffsetFromStart); + stream_save_to_file(flipper_format_stream, storage, file_name, FSOM_CREATE_ALWAYS); + + saved = true; + } while(0); + + furi_record_close(RECORD_STORAGE); + flipper_format_free(fff_data); + + return saved; +} \ No newline at end of file diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index 1bcb79d8fd..7a07d768a7 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -1,29 +1,28 @@ #pragma once #include "helpers/subrem_types.h" -#include +#include "helpers/subrem_presets.h" +#include "scenes/subrem_scene.h" -// #include +#include "helpers/txrx/subghz_txrx.h" +#include #include "views/remote.h" - -#include "scenes/subrem_scene.h" +#include "views/edit_menu.h" #include #include #include #include #include -#include #include +#include #include +#include #include -#include #include -#include - #include #include #include @@ -31,48 +30,38 @@ #define SUBREM_APP_FOLDER EXT_PATH("subghz_remote") #define SUBREM_MAX_LEN_NAME 64 -typedef struct { - uint32_t frequency; - uint8_t* data; -} FreqPreset; - -// Sub File preset -typedef struct { - FlipperFormat* fff_data; - FreqPreset freq_preset; - FuriString* file_path; - FuriString* protocaol_name; - FuriString* label; - SubGhzProtocolType type; - SubRemLoadSubState load_state; -} SubRemSubFilePreset; - -SubRemSubFilePreset* subrem_sub_file_preset_alloc(); - -void subrem_sub_file_preset_free(SubRemSubFilePreset* sub_preset); - typedef struct { Gui* gui; ViewDispatcher* view_dispatcher; SceneManager* scene_manager; NotificationApp* notifications; DialogsApp* dialogs; + Widget* widget; + Popup* popup; + TextInput* text_input; Submenu* submenu; + FuriString* file_path; char file_name_tmp[SUBREM_MAX_LEN_NAME]; SubRemViewRemote* subrem_remote_view; + SubRemViewEditMenu* subrem_edit_menu; - SubRemSubFilePreset* subs_preset[SubRemSubKeyNameMaxCount]; + SubRemMapPreset* map_preset; - SubGhzSetting* setting; - SubGhzEnvironment* environment; - SubGhzReceiver* receiver; - SubGhzTransmitter* transmitter; + SubGhzTxRx* txrx; - bool tx_running; + bool map_not_saved; uint8_t chusen_sub; } SubGhzRemoteApp; SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app); + +SubRemLoadMapState subrem_map_file_load(SubGhzRemoteApp* app, const char* file_path); + +void subrem_map_preset_reset(SubRemMapPreset* map_preset); + +bool subrem_save_map_to_file(SubGhzRemoteApp* app); + +void subrem_save_active_sub(void* context); \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/edit_menu.c b/applications/external/subghz_remote_new/views/edit_menu.c new file mode 100644 index 0000000000..9b88182b51 --- /dev/null +++ b/applications/external/subghz_remote_new/views/edit_menu.c @@ -0,0 +1,290 @@ +#include "edit_menu.h" +#include "../subghz_remote_app_i.h" + +#include +#include + +#define subrem_view_edit_menu_MAX_LABEL_LENGTH 12 + +#define FRAME_HEIGHT 12 + +struct SubRemViewEditMenu { + View* view; + SubRemViewEditMenuCallback callback; + void* context; +}; + +typedef struct { + FuriString* label; + FuriString* file_path; + SubRemLoadSubState sub_state; + + uint8_t chusen; +} SubRemViewEditMenuModel; + +void subrem_view_edit_menu_set_callback( + SubRemViewEditMenu* subrem_view_edit_menu, + SubRemViewEditMenuCallback callback, + void* context) { + furi_assert(subrem_view_edit_menu); + + subrem_view_edit_menu->callback = callback; + subrem_view_edit_menu->context = context; +} + +void subrem_view_edit_menu_add_data_to_show( + SubRemViewEditMenu* subrem_view_edit_remote, + uint8_t index, + FuriString* label, + FuriString* path, + SubRemLoadSubState state) { + furi_assert(subrem_view_edit_remote); + + with_view_model( + subrem_view_edit_remote->view, + SubRemViewEditMenuModel * model, + { + model->chusen = index; + if(!furi_string_empty(label)) { + furi_string_set(model->label, label); + } else { + furi_string_set(model->label, "Empty label"); + } + furi_string_set(model->file_path, path); + model->sub_state = state; + }, + true); +} + +uint8_t subrem_view_edit_menu_get_index(SubRemViewEditMenu* subrem_view_edit_remote) { + furi_assert(subrem_view_edit_remote); + uint8_t index; + + with_view_model( + subrem_view_edit_remote->view, + SubRemViewEditMenuModel * model, + { index = model->chusen; }, + true); + return index; +} + +void subrem_view_edit_menu_draw(Canvas* canvas, SubRemViewEditMenuModel* model) { + canvas_clear(canvas); + canvas_set_color(canvas, ColorBlack); + + canvas_clear(canvas); + + // Draw bottom btn + canvas_set_font(canvas, FontSecondary); + elements_button_left(canvas, "Back"); + elements_button_center(canvas, "Edit"); + elements_button_right(canvas, "Save"); + + // Draw top frame + canvas_draw_line(canvas, 1, 0, 125, 0); + canvas_draw_box(canvas, 0, 1, 127, FRAME_HEIGHT - 2); + canvas_draw_line(canvas, 1, FRAME_HEIGHT - 1, 125, FRAME_HEIGHT - 1); + + canvas_set_color(canvas, ColorWhite); + + // Draw btn name + canvas_set_font(canvas, FontPrimary); + switch(model->chusen) { + case SubRemSubKeyNameUp: + canvas_draw_str(canvas, 3, FRAME_HEIGHT - 2, "UP"); + break; + + case SubRemSubKeyNameDown: + canvas_draw_str(canvas, 3, FRAME_HEIGHT - 2, "DOWN"); + break; + + case SubRemSubKeyNameLeft: + canvas_draw_str(canvas, 3, FRAME_HEIGHT - 2, "LEFT"); + break; + + case SubRemSubKeyNameRight: + canvas_draw_str(canvas, 3, FRAME_HEIGHT - 2, "RIGHT"); + break; + + case SubRemSubKeyNameOk: + canvas_draw_str(canvas, 3, FRAME_HEIGHT - 2, "OK"); + break; + + default: + break; + } + + // Draw Label + canvas_set_font(canvas, FontSecondary); + elements_text_box( + canvas, + 38, + 2, + 127 - 38, + FRAME_HEIGHT, + AlignCenter, + AlignBottom, + furi_string_empty(model->label) ? "Empty label" : furi_string_get_cstr(model->label), + true); + + // Draw arrow + canvas_set_color(canvas, ColorBlack); + if(model->chusen != 0) { + canvas_draw_icon(canvas, 119, 13, &I_Pin_arrow_up_7x9); + } + if(model->chusen != 4) { + canvas_draw_icon_ex(canvas, 119, 42, &I_Pin_arrow_up_7x9, IconRotation180); + } + + // Draw file_path + if(model->sub_state == SubRemLoadSubStateOK) { + canvas_set_font(canvas, FontSecondary); + elements_text_box( + canvas, + 1, + FRAME_HEIGHT + 1, + 118, + (63 - FRAME_HEIGHT * 2), + AlignLeft, + AlignTop, + furi_string_get_cstr(model->file_path), + false); + } else if(furi_string_empty(model->file_path)) { + canvas_set_font(canvas, FontPrimary); + canvas_draw_str(canvas, 1, FRAME_HEIGHT * 2 - 2, "Button not set"); + } else { + canvas_set_font(canvas, FontPrimary); + canvas_draw_str(canvas, 1, FRAME_HEIGHT * 2 - 2, "ERR:"); + canvas_set_font(canvas, FontSecondary); + switch(model->sub_state) { + case SubRemLoadSubStateErrorNoFile: + canvas_draw_str(canvas, 26, FRAME_HEIGHT * 2 - 2, "File not found"); + break; + case SubRemLoadSubStateErrorFreq: + canvas_draw_str(canvas, 26, FRAME_HEIGHT * 2 - 2, "Bad frequency"); + break; + case SubRemLoadSubStateErrorMod: + canvas_draw_str(canvas, 26, FRAME_HEIGHT * 2 - 2, "Bad modulation"); + break; + case SubRemLoadSubStateErrorProtocol: + canvas_draw_str(canvas, 26, FRAME_HEIGHT * 2 - 2, "Unsupported protocol"); + break; + + default: + break; + } + elements_text_box( + canvas, + 1, + FRAME_HEIGHT * 2, + 118, + 30, + AlignLeft, + AlignTop, + furi_string_get_cstr(model->file_path), + false); + } +} + +bool subrem_view_edit_menu_input(InputEvent* event, void* context) { + furi_assert(context); + SubRemViewEditMenu* subrem_view_edit_menu = context; + + if((event->key == InputKeyBack || event->key == InputKeyLeft) && + event->type == InputTypeShort) { + subrem_view_edit_menu->callback( + SubRemCustomEventViewEditMenuBack, subrem_view_edit_menu->context); + return true; + } else if(event->key == InputKeyUp && event->type == InputTypeShort) { + with_view_model( + subrem_view_edit_menu->view, + SubRemViewEditMenuModel * model, + { + if(model->chusen > 0) { + model->chusen -= 1; + }; + }, + true); + subrem_view_edit_menu->callback( + SubRemCustomEventViewEditMenuUP, subrem_view_edit_menu->context); + return true; + } else if(event->key == InputKeyDown && event->type == InputTypeShort) { + with_view_model( + subrem_view_edit_menu->view, + SubRemViewEditMenuModel * model, + { + if(model->chusen < 4) { + model->chusen += 1; + }; + }, + true); + subrem_view_edit_menu->callback( + SubRemCustomEventViewEditMenuDOWN, subrem_view_edit_menu->context); + return true; + } else if(event->key == InputKeyOk && event->type == InputTypeShort) { + subrem_view_edit_menu->callback( + SubRemCustomEventViewEditMenuEdit, subrem_view_edit_menu->context); + return true; + } else if(event->key == InputKeyRight && event->type == InputTypeShort) { + subrem_view_edit_menu->callback( + SubRemCustomEventViewEditMenuSave, subrem_view_edit_menu->context); + return true; + } + + return true; +} + +void subrem_view_edit_menu_enter(void* context) { + furi_assert(context); +} + +void subrem_view_edit_menu_exit(void* context) { + furi_assert(context); +} + +SubRemViewEditMenu* subrem_view_edit_menu_alloc() { + SubRemViewEditMenu* subrem_view_edit_menu = malloc(sizeof(SubRemViewEditMenu)); + + // View allocation and configuration + subrem_view_edit_menu->view = view_alloc(); + view_allocate_model( + subrem_view_edit_menu->view, ViewModelTypeLocking, sizeof(SubRemViewEditMenuModel)); + view_set_context(subrem_view_edit_menu->view, subrem_view_edit_menu); + view_set_draw_callback( + subrem_view_edit_menu->view, (ViewDrawCallback)subrem_view_edit_menu_draw); + view_set_input_callback(subrem_view_edit_menu->view, subrem_view_edit_menu_input); + view_set_enter_callback(subrem_view_edit_menu->view, subrem_view_edit_menu_enter); + view_set_exit_callback(subrem_view_edit_menu->view, subrem_view_edit_menu_exit); + + with_view_model( + subrem_view_edit_menu->view, + SubRemViewEditMenuModel * model, + { + model->label = furi_string_alloc(); // furi_string_alloc_set_str("LABEL"); + model->file_path = furi_string_alloc(); // furi_string_alloc_set_str("FILE_PATH"); + + model->chusen = 0; + }, + true); + return subrem_view_edit_menu; +} + +void subrem_view_edit_menu_free(SubRemViewEditMenu* subghz_edit_menu) { + furi_assert(subghz_edit_menu); + + with_view_model( + subghz_edit_menu->view, + SubRemViewEditMenuModel * model, + { + furi_string_free(model->label); + furi_string_free(model->file_path); + }, + true); + view_free(subghz_edit_menu->view); + free(subghz_edit_menu); +} + +View* subrem_view_edit_menu_get_view(SubRemViewEditMenu* subrem_view_edit_menu) { + furi_assert(subrem_view_edit_menu); + return subrem_view_edit_menu->view; +} \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/edit_menu.h b/applications/external/subghz_remote_new/views/edit_menu.h new file mode 100644 index 0000000000..7ceb7fac04 --- /dev/null +++ b/applications/external/subghz_remote_new/views/edit_menu.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include "../helpers/subrem_custom_event.h" +#include "../helpers/subrem_presets.h" + +typedef struct SubRemViewEditMenu SubRemViewEditMenu; + +typedef void (*SubRemViewEditMenuCallback)(SubRemCustomEvent event, void* context); + +void subrem_view_edit_menu_set_callback( + SubRemViewEditMenu* subrem_view_edit_menu, + SubRemViewEditMenuCallback callback, + void* context); + +SubRemViewEditMenu* subrem_view_edit_menu_alloc(); + +void subrem_view_edit_menu_free(SubRemViewEditMenu* subrem_view_edit_menu); + +View* subrem_view_edit_menu_get_view(SubRemViewEditMenu* subrem_view_edit_menu); + +void subrem_view_edit_menu_add_data_to_show( + SubRemViewEditMenu* subrem_view_edit_remote, + uint8_t index, + FuriString* label, + FuriString* path, + SubRemLoadSubState state); + +uint8_t subrem_view_edit_menu_get_index(SubRemViewEditMenu* subrem_view_edit_remote); \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/remote.c b/applications/external/subghz_remote_new/views/remote.c index 1f867cd0b6..c2b41cfd68 100644 --- a/applications/external/subghz_remote_new/views/remote.c +++ b/applications/external/subghz_remote_new/views/remote.c @@ -4,7 +4,11 @@ #include #include -#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 12 +#include + +#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 30 +#define SUBREM_VIEW_REMOTE_LEFT_OFFSET 10 +#define SUBREM_VIEW_REMOTE_RIGHT_OFFSET 22 struct SubRemViewRemote { View* view; @@ -12,19 +16,8 @@ struct SubRemViewRemote { void* context; }; -// TODO: model typedef struct { - // FuriString* up_label; - // FuriString* down_label; - // FuriString* left_label; - // FuriString* right_label; - // FuriString* ok_label; - - char* up_label; - char* down_label; - char* left_label; - char* right_label; - char* ok_label; + char* labels[SubRemSubKeyNameMaxCount]; SubRemViewRemoteState state; @@ -41,49 +34,76 @@ void subrem_view_remote_set_callback( subrem_view_remote->context = context; } -void subrem_view_remote_add_data_to_show( +void subrem_view_remote_update_data_labels( SubRemViewRemote* subrem_view_remote, - const char* up_label, - const char* down_label, - const char* left_label, - const char* right_label, - const char* ok_label) { + SubRemSubFilePreset** subs_presets) { furi_assert(subrem_view_remote); + furi_assert(subs_presets); + + FuriString* labels[SubRemSubKeyNameMaxCount]; + SubRemSubFilePreset* sub_preset; + + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + sub_preset = subs_presets[i]; + switch(sub_preset->load_state) { + case SubRemLoadSubStateOK: + if(!furi_string_empty(sub_preset->label)) { + labels[i] = furi_string_alloc_set(sub_preset->label); + } else if(!furi_string_empty(sub_preset->file_path)) { + labels[i] = furi_string_alloc(); + path_extract_filename(sub_preset->file_path, labels[i], true); + } else { + labels[i] = furi_string_alloc_set("Empty Label"); + } + break; + + case SubRemLoadSubStateErrorNoFile: + labels[i] = furi_string_alloc_set("[X] Can't open file"); + break; + + case SubRemLoadSubStateErrorFreq: + case SubRemLoadSubStateErrorMod: + case SubRemLoadSubStateErrorProtocol: + labels[i] = furi_string_alloc_set("[X] Error in .sub file"); + break; + + default: + labels[i] = furi_string_alloc_set(""); + break; + } + } with_view_model( subrem_view_remote->view, SubRemViewRemoteModel * model, { - strncpy(model->up_label, up_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->down_label, down_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->left_label, left_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->right_label, right_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - strncpy(model->ok_label, ok_label, SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); - - // furi_string_set(model->up_label, up_label); - // furi_string_set(model->down_label, down_label); - // furi_string_set(model->left_label, left_label); - // furi_string_set(model->right_label, right_label); - // furi_string_set(model->ok_label, ok_label); + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + strncpy( + model->labels[i], + furi_string_get_cstr(labels[i]), + SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH); + } }, true); -} -void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn) { - furi_assert(subrem_view_remote); - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = presed_btn; }, - true); + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + furi_string_free(labels[i]); + } } void subrem_view_remote_set_state( SubRemViewRemote* subrem_view_remote, - SubRemViewRemoteState state) { + SubRemViewRemoteState state, + uint8_t presed_btn) { furi_assert(subrem_view_remote); with_view_model( - subrem_view_remote->view, SubRemViewRemoteModel * model, { model->state = state; }, true); + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { + model->state = state; + model->pressed_btn = presed_btn; + }, + true); } void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { @@ -103,24 +123,32 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { //Labels canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 10, 10, model->up_label); - canvas_draw_str(canvas, 10, 20, model->down_label); - canvas_draw_str(canvas, 10, 30, model->left_label); - canvas_draw_str(canvas, 10, 40, model->right_label); - canvas_draw_str(canvas, 10, 50, model->ok_label); - - // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); - // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); - // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); - // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); - // canvas_draw_str(canvas, 10, 10, furi_string_get_cstr(model->up_label)); + uint8_t y = 0; + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + elements_text_box( + canvas, + SUBREM_VIEW_REMOTE_LEFT_OFFSET, + y + 2, + 126 - SUBREM_VIEW_REMOTE_LEFT_OFFSET - SUBREM_VIEW_REMOTE_RIGHT_OFFSET, + 12, + AlignLeft, + AlignBottom, + model->labels[i], + false); + y += 10; + } - canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Hold=Exit."); + if(model->state == SubRemViewRemoteStateOFF) { + elements_button_left(canvas, "Back"); + elements_button_right(canvas, "Save"); + } else { + canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Hold=Exit."); + } //Status text and indicator canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13); - if(model->state == SubRemViewRemoteStateIdle) { + if(model->state == SubRemViewRemoteStateIdle || model->state == SubRemViewRemoteStateOFF) { canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Idle"); } else { switch(model->state) { @@ -155,10 +183,6 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { break; } } - //Repeat indicator - //canvas_draw_str_aligned(canvas, 125, 40, AlignRight, AlignBottom, "Repeat:"); - //canvas_draw_icon(canvas, 115, 39, &I_SubGHzRemote_Repeat_12x14); - //canvas_draw_str_aligned(canvas, 125, 62, AlignRight, AlignBottom, int_to_char(app->repeat)); } bool subrem_view_remote_input(InputEvent* event, void* context) { @@ -166,17 +190,6 @@ bool subrem_view_remote_input(InputEvent* event, void* context) { SubRemViewRemote* subrem_view_remote = context; if(event->key == InputKeyBack && event->type == InputTypeLong) { - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { - strcpy(model->up_label, "N/A"); - strcpy(model->down_label, "N/A"); - strcpy(model->left_label, "N/A"); - strcpy(model->right_label, "N/A"); - strcpy(model->ok_label, "N/A"); - }, - false); subrem_view_remote->callback(SubRemCustomEventViewRemoteBack, subrem_view_remote->context); return true; } else if(event->key == InputKeyBack && event->type == InputTypeShort) { @@ -248,23 +261,10 @@ SubRemViewRemote* subrem_view_remote_alloc() { { model->state = SubRemViewRemoteStateIdle; - model->up_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); - model->down_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); - model->left_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); - model->right_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); - model->ok_label = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); - - strcpy(model->up_label, "N/A"); - strcpy(model->down_label, "N/A"); - strcpy(model->left_label, "N/A"); - strcpy(model->right_label, "N/A"); - strcpy(model->ok_label, "N/A"); - - // model->up_label = furi_string_alloc_set_str("N/A"); - // model->down_label = furi_string_alloc_set_str("N/A"); - // model->left_label = furi_string_alloc_set_str("N/A"); - // model->right_label = furi_string_alloc_set_str("N/A"); - // model->ok_label = furi_string_alloc_set_str("N/A"); + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + model->labels[i] = malloc(sizeof(char) * SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH + 1); + strcpy(model->labels[i], ""); + } model->pressed_btn = 0; }, @@ -279,17 +279,9 @@ void subrem_view_remote_free(SubRemViewRemote* subghz_remote) { subghz_remote->view, SubRemViewRemoteModel * model, { - free(model->up_label); - free(model->down_label); - free(model->left_label); - free(model->right_label); - free(model->ok_label); - - // furi_string_free(model->up_label); - // furi_string_free(model->down_label); - // furi_string_free(model->left_label); - // furi_string_free(model->right_label); - // furi_string_free(model->ok_label); + for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) { + free(model->labels[i]); + } }, true); view_free(subghz_remote->view); diff --git a/applications/external/subghz_remote_new/views/remote.h b/applications/external/subghz_remote_new/views/remote.h index 76121cf8a0..5b1e8153ae 100644 --- a/applications/external/subghz_remote_new/views/remote.h +++ b/applications/external/subghz_remote_new/views/remote.h @@ -2,11 +2,13 @@ #include #include "../helpers/subrem_custom_event.h" +#include "../helpers/subrem_presets.h" typedef enum { SubRemViewRemoteStateIdle, SubRemViewRemoteStateLoading, SubRemViewRemoteStateSending, + SubRemViewRemoteStateOFF, } SubRemViewRemoteState; typedef struct SubRemViewRemote SubRemViewRemote; @@ -24,15 +26,11 @@ void subrem_view_remote_free(SubRemViewRemote* subrem_view_remote); View* subrem_view_remote_get_view(SubRemViewRemote* subrem_view_remote); -void subrem_view_remote_add_data_to_show( +void subrem_view_remote_update_data_labels( SubRemViewRemote* subrem_view_remote, - const char* up_label, - const char* down_label, - const char* left_label, - const char* right_label, - const char* ok_label); + SubRemSubFilePreset** subs_presets); -void subrem_view_remote_set_presed_btn(SubRemViewRemote* subrem_view_remote, uint8_t presed_btn); void subrem_view_remote_set_state( SubRemViewRemote* subrem_view_remote, - SubRemViewRemoteState state); \ No newline at end of file + SubRemViewRemoteState state, + uint8_t presed_btn); \ No newline at end of file From 3e09793b54439065d77a01a5bd74cad1138bc605 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 26 May 2023 18:14:15 +0300 Subject: [PATCH 77/92] Rename --- .../external/subghz_remote_new/application.fam | 10 +++++----- .../external/subghz_remote_new/subghz_remote_app_i.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/external/subghz_remote_new/application.fam b/applications/external/subghz_remote_new/application.fam index a232fb30f0..7590e46a59 100644 --- a/applications/external/subghz_remote_new/application.fam +++ b/applications/external/subghz_remote_new/application.fam @@ -1,16 +1,16 @@ App( - appid="subrem_remote_fap", - name="Sub-GHz Remote", + appid="subrem_configurator", + name="SubRem Configurator", apptype=FlipperAppType.EXTERNAL, entry_point="subghz_remote_app", requires=[ "gui", "dialogs", ], - stack_size=3 * 1024, + stack_size=2 * 1024, order=50, - fap_description="Remote control for transmission multiple *.sub files", - fap_category="Debug", #"Sub-Ghz" + fap_description="File Editor for the SubGhz Remote app", + fap_category="Sub-Ghz", fap_icon_assets="icons", fap_icon="icons/subrem_10px.png", ) \ No newline at end of file diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index 7a07d768a7..ce5f31009a 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -5,7 +5,7 @@ #include "scenes/subrem_scene.h" #include "helpers/txrx/subghz_txrx.h" -#include +#include #include "views/remote.h" #include "views/edit_menu.h" From 9c520c518837ef96c57e3a14e63de553672de658 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 26 May 2023 19:06:26 +0300 Subject: [PATCH 78/92] Rename + don't touch power and module type on start --- .../application.fam | 4 ++-- .../helpers/subrem_custom_event.h | 0 .../helpers/subrem_presets.c | 0 .../helpers/subrem_presets.h | 0 .../helpers/subrem_types.h | 0 .../helpers/txrx/Readme.md | 0 .../helpers/txrx/subghz_txrx.c | 0 .../helpers/txrx/subghz_txrx.h | 0 .../helpers/txrx/subghz_txrx_i.h | 0 .../icons/DolphinNice_96x59.png | Bin .../icons/remote_scene/ButtonDown_7x4.png | Bin .../icons/remote_scene/ButtonLeft_4x7.png | Bin .../icons/remote_scene/ButtonRight_4x7.png | Bin .../icons/remote_scene/ButtonUp_7x4.png | Bin .../icons/remote_scene/Ok_btn_9x9.png | Bin .../icons/remote_scene/Pin_arrow_up_7x9.png | Bin .../icons/remote_scene/Pin_cell_13x13.png | Bin .../icons/remote_scene/Pin_star_7x7.png | Bin .../icons/remote_scene/back_10px.png | Bin .../icons/sub1_10px.png | Bin .../icons/subrem_10px.png | Bin .../scenes/subrem_scene.c | 0 .../scenes/subrem_scene.h | 0 .../scenes/subrem_scene_config.h | 0 .../scenes/subrem_scene_edit_label.c | 0 .../scenes/subrem_scene_edit_menu.c | 0 .../scenes/subrem_scene_edit_preview.c | 0 .../scenes/subrem_scene_edit_submenu.c | 0 .../scenes/subrem_scene_enter_new_name.c | 0 .../scenes/subrem_scene_open_map_file.c | 0 .../scenes/subrem_scene_open_sub_file.c | 0 .../scenes/subrem_scene_start.c | 0 .../subghz_remote_app.c | 10 +++++----- .../subghz_remote_app_i.c | 0 .../subghz_remote_app_i.h | 0 .../views/edit_menu.c | 0 .../views/edit_menu.h | 0 .../views/remote.c | 0 .../views/remote.h | 0 39 files changed, 7 insertions(+), 7 deletions(-) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/application.fam (79%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/helpers/subrem_custom_event.h (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/helpers/subrem_presets.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/helpers/subrem_presets.h (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/helpers/subrem_types.h (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/helpers/txrx/Readme.md (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/helpers/txrx/subghz_txrx.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/helpers/txrx/subghz_txrx.h (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/helpers/txrx/subghz_txrx_i.h (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/DolphinNice_96x59.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/remote_scene/ButtonDown_7x4.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/remote_scene/ButtonLeft_4x7.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/remote_scene/ButtonRight_4x7.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/remote_scene/ButtonUp_7x4.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/remote_scene/Ok_btn_9x9.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/remote_scene/Pin_arrow_up_7x9.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/remote_scene/Pin_cell_13x13.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/remote_scene/Pin_star_7x7.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/remote_scene/back_10px.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/sub1_10px.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/icons/subrem_10px.png (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene.h (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene_config.h (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene_edit_label.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene_edit_menu.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene_edit_preview.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene_edit_submenu.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene_enter_new_name.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene_open_map_file.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene_open_sub_file.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/scenes/subrem_scene_start.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/subghz_remote_app.c (98%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/subghz_remote_app_i.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/subghz_remote_app_i.h (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/views/edit_menu.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/views/edit_menu.h (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/views/remote.c (100%) rename applications/external/{subghz_remote_new => subghz_remote_configurator}/views/remote.h (100%) diff --git a/applications/external/subghz_remote_new/application.fam b/applications/external/subghz_remote_configurator/application.fam similarity index 79% rename from applications/external/subghz_remote_new/application.fam rename to applications/external/subghz_remote_configurator/application.fam index 7590e46a59..9b164a0939 100644 --- a/applications/external/subghz_remote_new/application.fam +++ b/applications/external/subghz_remote_configurator/application.fam @@ -1,8 +1,8 @@ App( appid="subrem_configurator", - name="SubRem Configurator", + name="SubGHz Remote Configurator", apptype=FlipperAppType.EXTERNAL, - entry_point="subghz_remote_app", + entry_point="subghz_remote_config_app", requires=[ "gui", "dialogs", diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_configurator/helpers/subrem_custom_event.h similarity index 100% rename from applications/external/subghz_remote_new/helpers/subrem_custom_event.h rename to applications/external/subghz_remote_configurator/helpers/subrem_custom_event.h diff --git a/applications/external/subghz_remote_new/helpers/subrem_presets.c b/applications/external/subghz_remote_configurator/helpers/subrem_presets.c similarity index 100% rename from applications/external/subghz_remote_new/helpers/subrem_presets.c rename to applications/external/subghz_remote_configurator/helpers/subrem_presets.c diff --git a/applications/external/subghz_remote_new/helpers/subrem_presets.h b/applications/external/subghz_remote_configurator/helpers/subrem_presets.h similarity index 100% rename from applications/external/subghz_remote_new/helpers/subrem_presets.h rename to applications/external/subghz_remote_configurator/helpers/subrem_presets.h diff --git a/applications/external/subghz_remote_new/helpers/subrem_types.h b/applications/external/subghz_remote_configurator/helpers/subrem_types.h similarity index 100% rename from applications/external/subghz_remote_new/helpers/subrem_types.h rename to applications/external/subghz_remote_configurator/helpers/subrem_types.h diff --git a/applications/external/subghz_remote_new/helpers/txrx/Readme.md b/applications/external/subghz_remote_configurator/helpers/txrx/Readme.md similarity index 100% rename from applications/external/subghz_remote_new/helpers/txrx/Readme.md rename to applications/external/subghz_remote_configurator/helpers/txrx/Readme.md diff --git a/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.c b/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.c similarity index 100% rename from applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.c rename to applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.c diff --git a/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.h b/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.h similarity index 100% rename from applications/external/subghz_remote_new/helpers/txrx/subghz_txrx.h rename to applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.h diff --git a/applications/external/subghz_remote_new/helpers/txrx/subghz_txrx_i.h b/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx_i.h similarity index 100% rename from applications/external/subghz_remote_new/helpers/txrx/subghz_txrx_i.h rename to applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx_i.h diff --git a/applications/external/subghz_remote_new/icons/DolphinNice_96x59.png b/applications/external/subghz_remote_configurator/icons/DolphinNice_96x59.png similarity index 100% rename from applications/external/subghz_remote_new/icons/DolphinNice_96x59.png rename to applications/external/subghz_remote_configurator/icons/DolphinNice_96x59.png diff --git a/applications/external/subghz_remote_new/icons/remote_scene/ButtonDown_7x4.png b/applications/external/subghz_remote_configurator/icons/remote_scene/ButtonDown_7x4.png similarity index 100% rename from applications/external/subghz_remote_new/icons/remote_scene/ButtonDown_7x4.png rename to applications/external/subghz_remote_configurator/icons/remote_scene/ButtonDown_7x4.png diff --git a/applications/external/subghz_remote_new/icons/remote_scene/ButtonLeft_4x7.png b/applications/external/subghz_remote_configurator/icons/remote_scene/ButtonLeft_4x7.png similarity index 100% rename from applications/external/subghz_remote_new/icons/remote_scene/ButtonLeft_4x7.png rename to applications/external/subghz_remote_configurator/icons/remote_scene/ButtonLeft_4x7.png diff --git a/applications/external/subghz_remote_new/icons/remote_scene/ButtonRight_4x7.png b/applications/external/subghz_remote_configurator/icons/remote_scene/ButtonRight_4x7.png similarity index 100% rename from applications/external/subghz_remote_new/icons/remote_scene/ButtonRight_4x7.png rename to applications/external/subghz_remote_configurator/icons/remote_scene/ButtonRight_4x7.png diff --git a/applications/external/subghz_remote_new/icons/remote_scene/ButtonUp_7x4.png b/applications/external/subghz_remote_configurator/icons/remote_scene/ButtonUp_7x4.png similarity index 100% rename from applications/external/subghz_remote_new/icons/remote_scene/ButtonUp_7x4.png rename to applications/external/subghz_remote_configurator/icons/remote_scene/ButtonUp_7x4.png diff --git a/applications/external/subghz_remote_new/icons/remote_scene/Ok_btn_9x9.png b/applications/external/subghz_remote_configurator/icons/remote_scene/Ok_btn_9x9.png similarity index 100% rename from applications/external/subghz_remote_new/icons/remote_scene/Ok_btn_9x9.png rename to applications/external/subghz_remote_configurator/icons/remote_scene/Ok_btn_9x9.png diff --git a/applications/external/subghz_remote_new/icons/remote_scene/Pin_arrow_up_7x9.png b/applications/external/subghz_remote_configurator/icons/remote_scene/Pin_arrow_up_7x9.png similarity index 100% rename from applications/external/subghz_remote_new/icons/remote_scene/Pin_arrow_up_7x9.png rename to applications/external/subghz_remote_configurator/icons/remote_scene/Pin_arrow_up_7x9.png diff --git a/applications/external/subghz_remote_new/icons/remote_scene/Pin_cell_13x13.png b/applications/external/subghz_remote_configurator/icons/remote_scene/Pin_cell_13x13.png similarity index 100% rename from applications/external/subghz_remote_new/icons/remote_scene/Pin_cell_13x13.png rename to applications/external/subghz_remote_configurator/icons/remote_scene/Pin_cell_13x13.png diff --git a/applications/external/subghz_remote_new/icons/remote_scene/Pin_star_7x7.png b/applications/external/subghz_remote_configurator/icons/remote_scene/Pin_star_7x7.png similarity index 100% rename from applications/external/subghz_remote_new/icons/remote_scene/Pin_star_7x7.png rename to applications/external/subghz_remote_configurator/icons/remote_scene/Pin_star_7x7.png diff --git a/applications/external/subghz_remote_new/icons/remote_scene/back_10px.png b/applications/external/subghz_remote_configurator/icons/remote_scene/back_10px.png similarity index 100% rename from applications/external/subghz_remote_new/icons/remote_scene/back_10px.png rename to applications/external/subghz_remote_configurator/icons/remote_scene/back_10px.png diff --git a/applications/external/subghz_remote_new/icons/sub1_10px.png b/applications/external/subghz_remote_configurator/icons/sub1_10px.png similarity index 100% rename from applications/external/subghz_remote_new/icons/sub1_10px.png rename to applications/external/subghz_remote_configurator/icons/sub1_10px.png diff --git a/applications/external/subghz_remote_new/icons/subrem_10px.png b/applications/external/subghz_remote_configurator/icons/subrem_10px.png similarity index 100% rename from applications/external/subghz_remote_new/icons/subrem_10px.png rename to applications/external/subghz_remote_configurator/icons/subrem_10px.png diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene.c similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene.c rename to applications/external/subghz_remote_configurator/scenes/subrem_scene.c diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene.h b/applications/external/subghz_remote_configurator/scenes/subrem_scene.h similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene.h rename to applications/external/subghz_remote_configurator/scenes/subrem_scene.h diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_config.h b/applications/external/subghz_remote_configurator/scenes/subrem_scene_config.h similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene_config.h rename to applications/external/subghz_remote_configurator/scenes/subrem_scene_config.h diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_edit_label.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_edit_label.c similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene_edit_label.c rename to applications/external/subghz_remote_configurator/scenes/subrem_scene_edit_label.c diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_edit_menu.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_edit_menu.c similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene_edit_menu.c rename to applications/external/subghz_remote_configurator/scenes/subrem_scene_edit_menu.c diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_edit_preview.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_edit_preview.c similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene_edit_preview.c rename to applications/external/subghz_remote_configurator/scenes/subrem_scene_edit_preview.c diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_edit_submenu.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_edit_submenu.c similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene_edit_submenu.c rename to applications/external/subghz_remote_configurator/scenes/subrem_scene_edit_submenu.c diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_enter_new_name.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_enter_new_name.c similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene_enter_new_name.c rename to applications/external/subghz_remote_configurator/scenes/subrem_scene_enter_new_name.c diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_open_map_file.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_open_map_file.c similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene_open_map_file.c rename to applications/external/subghz_remote_configurator/scenes/subrem_scene_open_map_file.c diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_open_sub_file.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_open_sub_file.c similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene_open_sub_file.c rename to applications/external/subghz_remote_configurator/scenes/subrem_scene_open_sub_file.c diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_start.c similarity index 100% rename from applications/external/subghz_remote_new/scenes/subrem_scene_start.c rename to applications/external/subghz_remote_configurator/scenes/subrem_scene_start.c diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_configurator/subghz_remote_app.c similarity index 98% rename from applications/external/subghz_remote_new/subghz_remote_app.c rename to applications/external/subghz_remote_configurator/subghz_remote_app.c index e026fe4dea..84100a2339 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app.c +++ b/applications/external/subghz_remote_configurator/subghz_remote_app.c @@ -28,7 +28,7 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { //FURI_LOG_E(TAG, "Could not create folder %s", SUBREM_APP_FOLDER); } furi_record_close(RECORD_STORAGE); - + /* // Enable power for External CC1101 if it is connected furi_hal_subghz_enable_ext_power(); // Auto switch to internal radio if external radio is not available @@ -39,7 +39,7 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { } furi_hal_power_suppress_charge_enter(); - +*/ app->file_path = furi_string_alloc(); furi_string_set(app->file_path, SUBREM_APP_FOLDER); @@ -125,14 +125,14 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { void subghz_remote_app_free(SubGhzRemoteApp* app) { furi_assert(app); - + /* furi_hal_power_suppress_charge_exit(); // Disable power for External CC1101 if it was enabled and module is connected furi_hal_subghz_disable_ext_power(); // Reinit SPI handles for internal radio / nfc furi_hal_subghz_init_radio_type(SubGhzRadioInternal); - +*/ // Submenu view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDSubmenu); submenu_free(app->submenu); @@ -183,7 +183,7 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) { free(app); } -int32_t subghz_remote_app(void* p) { +int32_t subghz_remote_config_app(void* p) { UNUSED(p); SubGhzRemoteApp* subghz_remote_app = subghz_remote_app_alloc(); diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_configurator/subghz_remote_app_i.c similarity index 100% rename from applications/external/subghz_remote_new/subghz_remote_app_i.c rename to applications/external/subghz_remote_configurator/subghz_remote_app_i.c diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_configurator/subghz_remote_app_i.h similarity index 100% rename from applications/external/subghz_remote_new/subghz_remote_app_i.h rename to applications/external/subghz_remote_configurator/subghz_remote_app_i.h diff --git a/applications/external/subghz_remote_new/views/edit_menu.c b/applications/external/subghz_remote_configurator/views/edit_menu.c similarity index 100% rename from applications/external/subghz_remote_new/views/edit_menu.c rename to applications/external/subghz_remote_configurator/views/edit_menu.c diff --git a/applications/external/subghz_remote_new/views/edit_menu.h b/applications/external/subghz_remote_configurator/views/edit_menu.h similarity index 100% rename from applications/external/subghz_remote_new/views/edit_menu.h rename to applications/external/subghz_remote_configurator/views/edit_menu.h diff --git a/applications/external/subghz_remote_new/views/remote.c b/applications/external/subghz_remote_configurator/views/remote.c similarity index 100% rename from applications/external/subghz_remote_new/views/remote.c rename to applications/external/subghz_remote_configurator/views/remote.c diff --git a/applications/external/subghz_remote_new/views/remote.h b/applications/external/subghz_remote_configurator/views/remote.h similarity index 100% rename from applications/external/subghz_remote_new/views/remote.h rename to applications/external/subghz_remote_configurator/views/remote.h From 6dc1a0b6e8e8fcc3a35aefbec6277b6586fdb387 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 26 May 2023 19:11:06 +0300 Subject: [PATCH 79/92] rename again --- .../external/subghz_remote_configurator/application.fam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/external/subghz_remote_configurator/application.fam b/applications/external/subghz_remote_configurator/application.fam index 9b164a0939..00dc026971 100644 --- a/applications/external/subghz_remote_configurator/application.fam +++ b/applications/external/subghz_remote_configurator/application.fam @@ -1,6 +1,6 @@ App( appid="subrem_configurator", - name="SubGHz Remote Configurator", + name="Remote Configurator", apptype=FlipperAppType.EXTERNAL, entry_point="subghz_remote_config_app", requires=[ From e6790e50c67b267d2c88aeddf20572db709dfa4f Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 26 May 2023 19:17:27 +0300 Subject: [PATCH 80/92] fix crash --- .../scenes/subrem_scene_open_sub_file.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/applications/external/subghz_remote_configurator/scenes/subrem_scene_open_sub_file.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_open_sub_file.c index 75dc216704..fa74705949 100644 --- a/applications/external/subghz_remote_configurator/scenes/subrem_scene_open_sub_file.c +++ b/applications/external/subghz_remote_configurator/scenes/subrem_scene_open_sub_file.c @@ -11,21 +11,23 @@ SubRemLoadSubState subrem_scene_open_sub_file_dialog(SubGhzRemoteApp* app) { SubRemSubFilePreset* sub = app->map_preset->subs_preset[app->chusen_sub]; - FuriString* temp_file_path = furi_string_alloc_set(sub->file_path); + FuriString* temp_file_path = furi_string_alloc(); + + if(furi_string_empty(sub->file_path)) { + furi_string_set(temp_file_path, SUBGHZ_RAW_FOLDER); + } else { + furi_string_set(sub->file_path, SUBGHZ_RAW_FOLDER); + } SubRemLoadSubState ret = SubRemLoadSubStateNotSet; DialogsFileBrowserOptions browser_options; dialog_file_browser_set_basic_options(&browser_options, SUBGHZ_APP_EXTENSION, &I_sub1_10px); - browser_options.base_path = SUBGHZ_APP_FOLDER; + browser_options.base_path = SUBGHZ_RAW_FOLDER; // Input events and views are managed by file_select - if(!dialog_file_browser_show( - app->dialogs, - temp_file_path, - furi_string_empty(temp_file_path) ? NULL : temp_file_path, - &browser_options)) { + if(!dialog_file_browser_show(app->dialogs, temp_file_path, temp_file_path, &browser_options)) { } else { // Check sub file SubRemSubFilePreset* sub_candidate = subrem_sub_file_preset_alloc(); From c4cba38559e03b85ee6a4b510a74309ae9ad5678 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 26 May 2023 19:18:08 +0300 Subject: [PATCH 81/92] oops --- .../scenes/subrem_scene_open_sub_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/external/subghz_remote_configurator/scenes/subrem_scene_open_sub_file.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_open_sub_file.c index fa74705949..eb438cb928 100644 --- a/applications/external/subghz_remote_configurator/scenes/subrem_scene_open_sub_file.c +++ b/applications/external/subghz_remote_configurator/scenes/subrem_scene_open_sub_file.c @@ -16,7 +16,7 @@ SubRemLoadSubState subrem_scene_open_sub_file_dialog(SubGhzRemoteApp* app) { if(furi_string_empty(sub->file_path)) { furi_string_set(temp_file_path, SUBGHZ_RAW_FOLDER); } else { - furi_string_set(sub->file_path, SUBGHZ_RAW_FOLDER); + furi_string_set(temp_file_path, sub->file_path); } SubRemLoadSubState ret = SubRemLoadSubStateNotSet; From 858ab99cecf11cbf3d662b423b9d3f05406eb2d3 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 26 May 2023 19:21:26 +0300 Subject: [PATCH 82/92] don't put subrem_ in name by default --- .../scenes/subrem_scene_enter_new_name.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/applications/external/subghz_remote_configurator/scenes/subrem_scene_enter_new_name.c b/applications/external/subghz_remote_configurator/scenes/subrem_scene_enter_new_name.c index d33e070af5..b829723a3a 100644 --- a/applications/external/subghz_remote_configurator/scenes/subrem_scene_enter_new_name.c +++ b/applications/external/subghz_remote_configurator/scenes/subrem_scene_enter_new_name.c @@ -14,9 +14,8 @@ void subrem_scene_enter_new_name_on_enter(void* context) { // Setup view TextInput* text_input = app->text_input; - bool dev_name_empty = false; - strncpy(app->file_name_tmp, "subrem_", SUBREM_MAX_LEN_NAME); + //strncpy(app->file_name_tmp, "subrem_", SUBREM_MAX_LEN_NAME); text_input_set_header_text(text_input, "Map file Name"); text_input_set_result_callback( text_input, @@ -24,7 +23,7 @@ void subrem_scene_enter_new_name_on_enter(void* context) { app, app->file_name_tmp, 25, - dev_name_empty); + false); ValidatorIsFile* validator_is_file = validator_is_file_alloc_init( furi_string_get_cstr(app->file_path), SUBREM_APP_EXTENSION, ""); From 71a2d56ad35236416cb3cf9ce49428962f70fc19 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 26 May 2023 19:29:08 +0300 Subject: [PATCH 83/92] update docs --- documentation/SubGHzRemotePlugin.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/documentation/SubGHzRemotePlugin.md b/documentation/SubGHzRemotePlugin.md index fd48eeca2b..948d8389da 100644 --- a/documentation/SubGHzRemotePlugin.md +++ b/documentation/SubGHzRemotePlugin.md @@ -1,11 +1,21 @@ # Sub-GHz Remote + +# UPDATE!!!!!! +## Now you can create and edit map files directly on flipper, go into Applications->Sub-GHz->Remote Configurator + +
+
+
+ + ### The SubGHz Remote Tool *requires* the creation of custom user map with `.txt` extension in the `subghz_remote` folder on the sdcard. #### If these files are not exist or not configured properly, **you will receive an error each time you try to select wrong file in the UniRF Tool**. ## You can add as many `.txt` map files as you want, file name doesn't matter! + ## Incorrect or unconfigured file error If the `.txt` file has not been properly configured, the following error will be thrown when trying to run the UniRF Remix app: From 2f35e980ef18b40723151baf4d302758f0080cc0 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 26 May 2023 19:52:43 +0300 Subject: [PATCH 84/92] rename rename --- .../external/subghz_remote_configurator/application.fam | 2 +- documentation/SubGHzRemotePlugin.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/external/subghz_remote_configurator/application.fam b/applications/external/subghz_remote_configurator/application.fam index 00dc026971..f43dbcbd8e 100644 --- a/applications/external/subghz_remote_configurator/application.fam +++ b/applications/external/subghz_remote_configurator/application.fam @@ -1,6 +1,6 @@ App( appid="subrem_configurator", - name="Remote Configurator", + name="Remote Maker", apptype=FlipperAppType.EXTERNAL, entry_point="subghz_remote_config_app", requires=[ diff --git a/documentation/SubGHzRemotePlugin.md b/documentation/SubGHzRemotePlugin.md index 948d8389da..cbdc0995b5 100644 --- a/documentation/SubGHzRemotePlugin.md +++ b/documentation/SubGHzRemotePlugin.md @@ -2,7 +2,7 @@ # UPDATE!!!!!! -## Now you can create and edit map files directly on flipper, go into Applications->Sub-GHz->Remote Configurator +## Now you can create and edit map files directly on flipper, go into Applications->Sub-GHz->Remote Maker

From 9af6616882ca3f6981fe47f2b79f609637a692a8 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 27 May 2023 13:39:54 +0300 Subject: [PATCH 85/92] Archive, fix rename, show message to user --- .../archive/scenes/archive_scene_rename.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/applications/main/archive/scenes/archive_scene_rename.c b/applications/main/archive/scenes/archive_scene_rename.c index 346383162f..e6c728f03b 100644 --- a/applications/main/archive/scenes/archive_scene_rename.c +++ b/applications/main/archive/scenes/archive_scene_rename.c @@ -22,17 +22,21 @@ void archive_scene_rename_on_enter(void* context) { TextInput* text_input = archive->text_input; ArchiveFile_t* current = archive_get_current_file(archive->browser); - FuriString* path_name; - path_name = furi_string_alloc(); + FuriString* path_name = furi_string_alloc(); + FuriString* path_folder = furi_string_alloc(); if(current->type == ArchiveFileTypeFolder) { + // Set file ext to empty since we need to see folder name here + strcpy(archive->file_extension, ""); + // Extract folder name and copy into text_store path_extract_basename(furi_string_get_cstr(current->path), path_name); strlcpy(archive->text_store, furi_string_get_cstr(path_name), MAX_NAME_LEN); text_input_set_header_text(text_input, "Rename directory:"); } else /*if(current->type != ArchiveFileTypeUnknown) */ { + // Extract file name and copy into text_store path_extract_filename(current->path, path_name, true); strlcpy(archive->text_store, furi_string_get_cstr(path_name), MAX_NAME_LEN); - + // Extract file extension for validator and rename func path_extract_extension(current->path, archive->file_extension, MAX_EXT_LEN); text_input_set_header_text(text_input, "Rename file:"); } /*else { @@ -41,6 +45,9 @@ void archive_scene_rename_on_enter(void* context) { text_input_set_header_text(text_input, "Rename unknown file:"); }*/ + // Get current folder (for file) or previous folder (for folder) for validator + path_extract_dirname(furi_string_get_cstr(current->path), path_folder); + text_input_set_result_callback( text_input, archive_scene_rename_text_input_callback, @@ -49,7 +56,13 @@ void archive_scene_rename_on_enter(void* context) { MAX_TEXT_INPUT_LEN, false); + // Init validator to show message to user that name already exist + ValidatorIsFile* validator_is_file = validator_is_file_alloc_init( + furi_string_get_cstr(path_folder), archive->file_extension, archive->text_store); + text_input_set_validator(text_input, validator_is_file_callback, validator_is_file); + furi_string_free(path_name); + furi_string_free(path_folder); view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewTextInput); } From 6208337f618583cbd62586f6a5d1a623206d0840 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 27 May 2023 16:51:54 +0300 Subject: [PATCH 86/92] Merge tiktok and ytshorts remote into one by @Willy-JL --- applications/external/hid_app/hid.c | 46 +--- applications/external/hid_app/hid.h | 6 +- applications/external/hid_app/views.h | 3 +- .../views/{hid_ytshorts.c => hid_tikshorts.c} | 143 +++++----- .../external/hid_app/views/hid_tikshorts.h | 14 + .../external/hid_app/views/hid_tiktok.c | 256 ------------------ .../external/hid_app/views/hid_tiktok.h | 14 - .../external/hid_app/views/hid_ytshorts.h | 14 - 8 files changed, 102 insertions(+), 394 deletions(-) rename applications/external/hid_app/views/{hid_ytshorts.c => hid_tikshorts.c} (59%) create mode 100644 applications/external/hid_app/views/hid_tikshorts.h delete mode 100644 applications/external/hid_app/views/hid_tiktok.c delete mode 100644 applications/external/hid_app/views/hid_tiktok.h delete mode 100644 applications/external/hid_app/views/hid_ytshorts.h diff --git a/applications/external/hid_app/hid.c b/applications/external/hid_app/hid.c index f4f59b435b..28c9ff1671 100644 --- a/applications/external/hid_app/hid.c +++ b/applications/external/hid_app/hid.c @@ -11,8 +11,7 @@ enum HidDebugSubmenuIndex { HidSubmenuIndexKeyboard, HidSubmenuIndexNumpad, HidSubmenuIndexMedia, - HidSubmenuIndexTikTok, - HidSubmenuIndexYTShorts, + HidSubmenuIndexTikShorts, HidSubmenuIndexMouse, HidSubmenuIndexMouseClicker, HidSubmenuIndexMouseJiggler, @@ -39,12 +38,9 @@ static void hid_submenu_callback(void* context, uint32_t index) { } else if(index == HidSubmenuIndexMouse) { app->view_id = HidViewMouse; view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouse); - } else if(index == HidSubmenuIndexTikTok) { - app->view_id = BtHidViewTikTok; - view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewTikTok); - } else if(index == HidSubmenuIndexYTShorts) { - app->view_id = BtHidViewYTShorts; - view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewYTShorts); + } else if(index == HidSubmenuIndexTikShorts) { + app->view_id = BtHidViewTikShorts; + view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewTikShorts); } else if(index == HidSubmenuIndexMouseClicker) { app->view_id = HidViewMouseClicker; view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouseClicker); @@ -73,8 +69,7 @@ static void bt_hid_connection_status_changed_callback(BtStatus status, void* con hid_mouse_set_connected_status(hid->hid_mouse, connected); hid_mouse_clicker_set_connected_status(hid->hid_mouse_clicker, connected); hid_mouse_jiggler_set_connected_status(hid->hid_mouse_jiggler, connected); - hid_tiktok_set_connected_status(hid->hid_tiktok, connected); - hid_ytshorts_set_connected_status(hid->hid_ytshorts, connected); + hid_tikshorts_set_connected_status(hid->hid_tikshorts, connected); } static void hid_dialog_callback(DialogExResult result, void* context) { @@ -137,14 +132,8 @@ Hid* hid_alloc(HidTransport transport) { if(app->transport == HidTransportBle) { submenu_add_item( app->device_type_submenu, - "TikTok Controller", - HidSubmenuIndexTikTok, - hid_submenu_callback, - app); - submenu_add_item( - app->device_type_submenu, - "YT Shorts Controller", - HidSubmenuIndexYTShorts, + "TikTok / YT Shorts", + HidSubmenuIndexTikShorts, hid_submenu_callback, app); } @@ -215,17 +204,11 @@ Hid* hid_app_alloc_view(void* context) { view_dispatcher_add_view( app->view_dispatcher, HidViewMedia, hid_media_get_view(app->hid_media)); - // TikTok view - app->hid_tiktok = hid_tiktok_alloc(app); - view_set_previous_callback(hid_tiktok_get_view(app->hid_tiktok), hid_exit_confirm_view); + // TikTok / YT Shorts view + app->hid_tikshorts = hid_tikshorts_alloc(app); + view_set_previous_callback(hid_tikshorts_get_view(app->hid_tikshorts), hid_exit_confirm_view); view_dispatcher_add_view( - app->view_dispatcher, BtHidViewTikTok, hid_tiktok_get_view(app->hid_tiktok)); - - // YTShorts view - app->hid_ytshorts = hid_ytshorts_alloc(app); - view_set_previous_callback(hid_ytshorts_get_view(app->hid_ytshorts), hid_exit_confirm_view); - view_dispatcher_add_view( - app->view_dispatcher, BtHidViewYTShorts, hid_ytshorts_get_view(app->hid_ytshorts)); + app->view_dispatcher, BtHidViewTikShorts, hid_tikshorts_get_view(app->hid_tikshorts)); // Mouse view app->hid_mouse = hid_mouse_alloc(app); @@ -241,6 +224,7 @@ Hid* hid_app_alloc_view(void* context) { app->view_dispatcher, HidViewMouseClicker, hid_mouse_clicker_get_view(app->hid_mouse_clicker)); + // Mouse jiggler view app->hid_mouse_jiggler = hid_mouse_jiggler_alloc(app); view_set_previous_callback( @@ -282,10 +266,8 @@ void hid_free(Hid* app) { hid_mouse_clicker_free(app->hid_mouse_clicker); view_dispatcher_remove_view(app->view_dispatcher, HidViewMouseJiggler); hid_mouse_jiggler_free(app->hid_mouse_jiggler); - view_dispatcher_remove_view(app->view_dispatcher, BtHidViewTikTok); - hid_tiktok_free(app->hid_tiktok); - view_dispatcher_remove_view(app->view_dispatcher, BtHidViewYTShorts); - hid_ytshorts_free(app->hid_ytshorts); + view_dispatcher_remove_view(app->view_dispatcher, BtHidViewTikShorts); + hid_tikshorts_free(app->hid_tikshorts); view_dispatcher_free(app->view_dispatcher); // Close records diff --git a/applications/external/hid_app/hid.h b/applications/external/hid_app/hid.h index 1a533de99f..4a8cd2a987 100644 --- a/applications/external/hid_app/hid.h +++ b/applications/external/hid_app/hid.h @@ -23,8 +23,7 @@ #include "views/hid_media.h" #include "views/hid_mouse.h" #include "views/hid_mouse_jiggler.h" -#include "views/hid_tiktok.h" -#include "views/hid_ytshorts.h" +#include "views/hid_tikshorts.h" #include "views/hid_mouse_clicker.h" #define HID_BT_KEYS_STORAGE_NAME ".bt_hid.keys" @@ -51,8 +50,7 @@ struct Hid { HidMouse* hid_mouse; HidMouseClicker* hid_mouse_clicker; HidMouseJiggler* hid_mouse_jiggler; - HidTikTok* hid_tiktok; - HidYTShorts* hid_ytshorts; + HidTikShorts* hid_tikshorts; HidTransport transport; uint32_t view_id; diff --git a/applications/external/hid_app/views.h b/applications/external/hid_app/views.h index 2ec17bb339..5d02220cd6 100644 --- a/applications/external/hid_app/views.h +++ b/applications/external/hid_app/views.h @@ -8,7 +8,6 @@ typedef enum { HidViewMouse, HidViewMouseClicker, HidViewMouseJiggler, - BtHidViewTikTok, - BtHidViewYTShorts, + BtHidViewTikShorts, HidViewExitConfirm, } HidView; diff --git a/applications/external/hid_app/views/hid_ytshorts.c b/applications/external/hid_app/views/hid_tikshorts.c similarity index 59% rename from applications/external/hid_app/views/hid_ytshorts.c rename to applications/external/hid_app/views/hid_tikshorts.c index 3590916405..0e156fdf05 100644 --- a/applications/external/hid_app/views/hid_ytshorts.c +++ b/applications/external/hid_app/views/hid_tikshorts.c @@ -1,12 +1,12 @@ -#include "hid_ytshorts.h" +#include "hid_tikshorts.h" #include "../hid.h" #include #include "hid_icons.h" -#define TAG "HidYTShorts" +#define TAG "HidTikShorts" -struct HidYTShorts { +struct HidTikShorts { View* view; Hid* hid; }; @@ -21,11 +21,11 @@ typedef struct { bool is_cursor_set; bool back_mouse_pressed; HidTransport transport; -} HidYTShortsModel; +} HidTikShortsModel; -static void hid_ytshorts_draw_callback(Canvas* canvas, void* context) { +static void hid_tikshorts_draw_callback(Canvas* canvas, void* context) { furi_assert(context); - HidYTShortsModel* model = context; + HidTikShortsModel* model = context; // Header if(model->transport == HidTransportBle) { @@ -37,7 +37,8 @@ static void hid_ytshorts_draw_callback(Canvas* canvas, void* context) { } canvas_set_font(canvas, FontPrimary); - elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Shorts"); + elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "TikTok /"); + elements_multiline_text_aligned(canvas, 3, 18, AlignLeft, AlignTop, "YT Shorts"); canvas_set_font(canvas, FontSecondary); // Keypad circles @@ -109,22 +110,21 @@ static void hid_ytshorts_draw_callback(Canvas* canvas, void* context) { elements_multiline_text_aligned(canvas, 13, 62, AlignLeft, AlignBottom, "Hold to exit"); } -static void hid_ytshorts_reset_cursor(HidYTShorts* hid_ytshorts) { +static void hid_tikshorts_reset_cursor(HidTikShorts* hid_tikshorts) { // Set cursor to the phone's left up corner // Delays to guarantee one packet per connection interval for(size_t i = 0; i < 8; i++) { - hid_hal_mouse_move(hid_ytshorts->hid, -127, -127); + hid_hal_mouse_move(hid_tikshorts->hid, -127, -127); furi_delay_ms(50); } // Move cursor from the corner - hid_hal_mouse_move(hid_ytshorts->hid, 40, 120); - hid_hal_mouse_move(hid_ytshorts->hid, 0, 120); + hid_hal_mouse_move(hid_tikshorts->hid, 20, 120); furi_delay_ms(50); } -static void hid_ytshorts_process_press( - HidYTShorts* hid_ytshorts, - HidYTShortsModel* model, +static void hid_tikshorts_process_press( + HidTikShorts* hid_tikshorts, + HidTikShortsModel* model, InputEvent* event) { if(event->key == InputKeyUp) { model->up_pressed = true; @@ -132,10 +132,10 @@ static void hid_ytshorts_process_press( model->down_pressed = true; } else if(event->key == InputKeyLeft) { model->left_pressed = true; - hid_hal_consumer_key_press(hid_ytshorts->hid, HID_CONSUMER_VOLUME_DECREMENT); + hid_hal_consumer_key_press(hid_tikshorts->hid, HID_CONSUMER_VOLUME_DECREMENT); } else if(event->key == InputKeyRight) { model->right_pressed = true; - hid_hal_consumer_key_press(hid_ytshorts->hid, HID_CONSUMER_VOLUME_INCREMENT); + hid_hal_consumer_key_press(hid_tikshorts->hid, HID_CONSUMER_VOLUME_INCREMENT); } else if(event->key == InputKeyOk) { model->ok_pressed = true; } else if(event->key == InputKeyBack) { @@ -143,9 +143,9 @@ static void hid_ytshorts_process_press( } } -static void hid_ytshorts_process_release( - HidYTShorts* hid_ytshorts, - HidYTShortsModel* model, +static void hid_tikshorts_process_release( + HidTikShorts* hid_tikshorts, + HidTikShortsModel* model, InputEvent* event) { if(event->key == InputKeyUp) { model->up_pressed = false; @@ -153,10 +153,10 @@ static void hid_ytshorts_process_release( model->down_pressed = false; } else if(event->key == InputKeyLeft) { model->left_pressed = false; - hid_hal_consumer_key_release(hid_ytshorts->hid, HID_CONSUMER_VOLUME_DECREMENT); + hid_hal_consumer_key_release(hid_tikshorts->hid, HID_CONSUMER_VOLUME_DECREMENT); } else if(event->key == InputKeyRight) { model->right_pressed = false; - hid_hal_consumer_key_release(hid_ytshorts->hid, HID_CONSUMER_VOLUME_INCREMENT); + hid_hal_consumer_key_release(hid_tikshorts->hid, HID_CONSUMER_VOLUME_INCREMENT); } else if(event->key == InputKeyOk) { model->ok_pressed = false; } else if(event->key == InputKeyBack) { @@ -164,62 +164,61 @@ static void hid_ytshorts_process_release( } } -static bool hid_ytshorts_input_callback(InputEvent* event, void* context) { +static bool hid_tikshorts_input_callback(InputEvent* event, void* context) { furi_assert(context); - HidYTShorts* hid_ytshorts = context; + HidTikShorts* hid_tikshorts = context; bool consumed = false; with_view_model( - hid_ytshorts->view, - HidYTShortsModel * model, + hid_tikshorts->view, + HidTikShortsModel * model, { if(event->type == InputTypePress) { - hid_ytshorts_process_press(hid_ytshorts, model, event); + hid_tikshorts_process_press(hid_tikshorts, model, event); if(model->connected && !model->is_cursor_set) { - hid_ytshorts_reset_cursor(hid_ytshorts); + hid_tikshorts_reset_cursor(hid_tikshorts); model->is_cursor_set = true; } consumed = true; } else if(event->type == InputTypeRelease) { - hid_ytshorts_process_release(hid_ytshorts, model, event); + hid_tikshorts_process_release(hid_tikshorts, model, event); consumed = true; } else if(event->type == InputTypeShort) { if(event->key == InputKeyOk) { - hid_hal_mouse_press(hid_ytshorts->hid, HID_MOUSE_BTN_LEFT); - furi_delay_ms(50); - hid_hal_mouse_release(hid_ytshorts->hid, HID_MOUSE_BTN_LEFT); - furi_delay_ms(50); - hid_hal_mouse_press(hid_ytshorts->hid, HID_MOUSE_BTN_LEFT); - furi_delay_ms(50); - hid_hal_mouse_release(hid_ytshorts->hid, HID_MOUSE_BTN_LEFT); + hid_hal_mouse_press(hid_tikshorts->hid, HID_MOUSE_BTN_LEFT); + furi_delay_ms(25); + hid_hal_mouse_release(hid_tikshorts->hid, HID_MOUSE_BTN_LEFT); + furi_delay_ms(100); + hid_hal_mouse_press(hid_tikshorts->hid, HID_MOUSE_BTN_LEFT); + furi_delay_ms(25); + hid_hal_mouse_release(hid_tikshorts->hid, HID_MOUSE_BTN_LEFT); consumed = true; } else if(event->key == InputKeyDown) { - // Swipe to new video - hid_hal_mouse_scroll(hid_ytshorts->hid, 6); - hid_hal_mouse_scroll(hid_ytshorts->hid, 8); - hid_hal_mouse_scroll(hid_ytshorts->hid, 10); - hid_hal_mouse_scroll(hid_ytshorts->hid, 8); - hid_hal_mouse_scroll(hid_ytshorts->hid, 6); + // Swipe to next video + hid_hal_mouse_scroll(hid_tikshorts->hid, 6); + hid_hal_mouse_scroll(hid_tikshorts->hid, 8); + hid_hal_mouse_scroll(hid_tikshorts->hid, 10); + hid_hal_mouse_scroll(hid_tikshorts->hid, 8); + hid_hal_mouse_scroll(hid_tikshorts->hid, 6); consumed = true; } else if(event->key == InputKeyUp) { // Swipe to previous video - hid_hal_mouse_scroll(hid_ytshorts->hid, -6); - hid_hal_mouse_scroll(hid_ytshorts->hid, -8); - hid_hal_mouse_scroll(hid_ytshorts->hid, -10); - hid_hal_mouse_scroll(hid_ytshorts->hid, -8); - hid_hal_mouse_scroll(hid_ytshorts->hid, -6); + hid_hal_mouse_scroll(hid_tikshorts->hid, -6); + hid_hal_mouse_scroll(hid_tikshorts->hid, -8); + hid_hal_mouse_scroll(hid_tikshorts->hid, -10); + hid_hal_mouse_scroll(hid_tikshorts->hid, -8); + hid_hal_mouse_scroll(hid_tikshorts->hid, -6); consumed = true; } else if(event->key == InputKeyBack) { // Pause - hid_hal_mouse_press(hid_ytshorts->hid, HID_MOUSE_BTN_LEFT); - furi_delay_ms(50); - hid_hal_mouse_release(hid_ytshorts->hid, HID_MOUSE_BTN_LEFT); + hid_hal_mouse_press(hid_tikshorts->hid, HID_MOUSE_BTN_LEFT); furi_delay_ms(50); + hid_hal_mouse_release(hid_tikshorts->hid, HID_MOUSE_BTN_LEFT); consumed = true; } } else if(event->type == InputTypeLong) { if(event->key == InputKeyBack) { - hid_hal_consumer_key_release_all(hid_ytshorts->hid); + hid_hal_consumer_key_release_all(hid_tikshorts->hid); model->is_cursor_set = false; consumed = false; } @@ -230,40 +229,40 @@ static bool hid_ytshorts_input_callback(InputEvent* event, void* context) { return consumed; } -HidYTShorts* hid_ytshorts_alloc(Hid* bt_hid) { - HidYTShorts* hid_ytshorts = malloc(sizeof(HidYTShorts)); - hid_ytshorts->hid = bt_hid; - hid_ytshorts->view = view_alloc(); - view_set_context(hid_ytshorts->view, hid_ytshorts); - view_allocate_model(hid_ytshorts->view, ViewModelTypeLocking, sizeof(HidYTShortsModel)); - view_set_draw_callback(hid_ytshorts->view, hid_ytshorts_draw_callback); - view_set_input_callback(hid_ytshorts->view, hid_ytshorts_input_callback); +HidTikShorts* hid_tikshorts_alloc(Hid* bt_hid) { + HidTikShorts* hid_tikshorts = malloc(sizeof(HidTikShorts)); + hid_tikshorts->hid = bt_hid; + hid_tikshorts->view = view_alloc(); + view_set_context(hid_tikshorts->view, hid_tikshorts); + view_allocate_model(hid_tikshorts->view, ViewModelTypeLocking, sizeof(HidTikShortsModel)); + view_set_draw_callback(hid_tikshorts->view, hid_tikshorts_draw_callback); + view_set_input_callback(hid_tikshorts->view, hid_tikshorts_input_callback); with_view_model( - hid_ytshorts->view, - HidYTShortsModel * model, + hid_tikshorts->view, + HidTikShortsModel * model, { model->transport = bt_hid->transport; }, true); - return hid_ytshorts; + return hid_tikshorts; } -void hid_ytshorts_free(HidYTShorts* hid_ytshorts) { - furi_assert(hid_ytshorts); - view_free(hid_ytshorts->view); - free(hid_ytshorts); +void hid_tikshorts_free(HidTikShorts* hid_tikshorts) { + furi_assert(hid_tikshorts); + view_free(hid_tikshorts->view); + free(hid_tikshorts); } -View* hid_ytshorts_get_view(HidYTShorts* hid_ytshorts) { - furi_assert(hid_ytshorts); - return hid_ytshorts->view; +View* hid_tikshorts_get_view(HidTikShorts* hid_tikshorts) { + furi_assert(hid_tikshorts); + return hid_tikshorts->view; } -void hid_ytshorts_set_connected_status(HidYTShorts* hid_ytshorts, bool connected) { - furi_assert(hid_ytshorts); +void hid_tikshorts_set_connected_status(HidTikShorts* hid_tikshorts, bool connected) { + furi_assert(hid_tikshorts); with_view_model( - hid_ytshorts->view, - HidYTShortsModel * model, + hid_tikshorts->view, + HidTikShortsModel * model, { model->connected = connected; model->is_cursor_set = false; diff --git a/applications/external/hid_app/views/hid_tikshorts.h b/applications/external/hid_app/views/hid_tikshorts.h new file mode 100644 index 0000000000..5604962ee8 --- /dev/null +++ b/applications/external/hid_app/views/hid_tikshorts.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +typedef struct Hid Hid; +typedef struct HidTikShorts HidTikShorts; + +HidTikShorts* hid_tikshorts_alloc(Hid* bt_hid); + +void hid_tikshorts_free(HidTikShorts* hid_tikshorts); + +View* hid_tikshorts_get_view(HidTikShorts* hid_tikshorts); + +void hid_tikshorts_set_connected_status(HidTikShorts* hid_tikshorts, bool connected); diff --git a/applications/external/hid_app/views/hid_tiktok.c b/applications/external/hid_app/views/hid_tiktok.c deleted file mode 100644 index 4dfbde4eb2..0000000000 --- a/applications/external/hid_app/views/hid_tiktok.c +++ /dev/null @@ -1,256 +0,0 @@ -#include "hid_tiktok.h" -#include "../hid.h" -#include - -#include "hid_icons.h" - -#define TAG "HidTikTok" - -struct HidTikTok { - View* view; - Hid* hid; -}; - -typedef struct { - bool left_pressed; - bool up_pressed; - bool right_pressed; - bool down_pressed; - bool ok_pressed; - bool connected; - bool is_cursor_set; - bool back_mouse_pressed; - HidTransport transport; -} HidTikTokModel; - -static void hid_tiktok_draw_callback(Canvas* canvas, void* context) { - furi_assert(context); - HidTikTokModel* model = context; - - // Header - if(model->transport == HidTransportBle) { - if(model->connected) { - canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15); - } else { - canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15); - } - } - - canvas_set_font(canvas, FontPrimary); - elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "TikTok"); - canvas_set_font(canvas, FontSecondary); - - // Keypad circles - canvas_draw_icon(canvas, 58, 3, &I_OutCircles); - - // Pause - if(model->back_mouse_pressed) { - canvas_set_bitmap_mode(canvas, 1); - canvas_draw_icon(canvas, 107, 33, &I_Pressed_Button_19x19); - canvas_set_bitmap_mode(canvas, 0); - canvas_set_color(canvas, ColorWhite); - } - canvas_draw_icon(canvas, 113, 37, &I_Pause_icon_9x9); - canvas_set_color(canvas, ColorBlack); - - // Up - if(model->up_pressed) { - canvas_set_bitmap_mode(canvas, 1); - canvas_draw_icon(canvas, 68, 6, &I_S_UP); - canvas_set_bitmap_mode(canvas, 0); - canvas_set_color(canvas, ColorWhite); - } - canvas_draw_icon(canvas, 80, 8, &I_Arr_up_7x9); - canvas_set_color(canvas, ColorBlack); - - // Down - if(model->down_pressed) { - canvas_set_bitmap_mode(canvas, 1); - canvas_draw_icon(canvas, 68, 36, &I_S_DOWN); - canvas_set_bitmap_mode(canvas, 0); - canvas_set_color(canvas, ColorWhite); - } - canvas_draw_icon(canvas, 80, 40, &I_Arr_dwn_7x9); - canvas_set_color(canvas, ColorBlack); - - // Left - if(model->left_pressed) { - canvas_set_bitmap_mode(canvas, 1); - canvas_draw_icon(canvas, 61, 13, &I_S_LEFT); - canvas_set_bitmap_mode(canvas, 0); - canvas_set_color(canvas, ColorWhite); - } - canvas_draw_icon(canvas, 64, 25, &I_Voldwn_6x6); - canvas_set_color(canvas, ColorBlack); - - // Right - if(model->right_pressed) { - canvas_set_bitmap_mode(canvas, 1); - canvas_draw_icon(canvas, 91, 13, &I_S_RIGHT); - canvas_set_bitmap_mode(canvas, 0); - canvas_set_color(canvas, ColorWhite); - } - canvas_draw_icon(canvas, 95, 25, &I_Volup_8x6); - canvas_set_color(canvas, ColorBlack); - - // Ok - if(model->ok_pressed) { - canvas_set_bitmap_mode(canvas, 1); - canvas_draw_icon(canvas, 74, 19, &I_Pressed_Button_19x19); - canvas_set_bitmap_mode(canvas, 0); - canvas_set_color(canvas, ColorWhite); - } - canvas_draw_icon(canvas, 78, 25, &I_Like_def_11x9); - canvas_set_color(canvas, ColorBlack); - - // Exit - canvas_draw_icon(canvas, 0, 54, &I_Pin_back_arrow_10x8); - canvas_set_font(canvas, FontSecondary); - elements_multiline_text_aligned(canvas, 13, 62, AlignLeft, AlignBottom, "Hold to exit"); -} - -static void hid_tiktok_reset_cursor(HidTikTok* hid_tiktok) { - // Set cursor to the phone's left up corner - // Delays to guarantee one packet per connection interval - for(size_t i = 0; i < 8; i++) { - hid_hal_mouse_move(hid_tiktok->hid, -127, -127); - furi_delay_ms(50); - } - // Move cursor from the corner - hid_hal_mouse_move(hid_tiktok->hid, 40, 120); - hid_hal_mouse_move(hid_tiktok->hid, 0, 120); - furi_delay_ms(50); -} - -static void - hid_tiktok_process_press(HidTikTok* hid_tiktok, HidTikTokModel* model, InputEvent* event) { - if(event->key == InputKeyUp) { - model->up_pressed = true; - } else if(event->key == InputKeyDown) { - model->down_pressed = true; - } else if(event->key == InputKeyLeft) { - model->left_pressed = true; - hid_hal_consumer_key_press(hid_tiktok->hid, HID_CONSUMER_VOLUME_DECREMENT); - } else if(event->key == InputKeyRight) { - model->right_pressed = true; - hid_hal_consumer_key_press(hid_tiktok->hid, HID_CONSUMER_VOLUME_INCREMENT); - } else if(event->key == InputKeyOk) { - model->ok_pressed = true; - } else if(event->key == InputKeyBack) { - model->back_mouse_pressed = true; - } -} - -static void - hid_tiktok_process_release(HidTikTok* hid_tiktok, HidTikTokModel* model, InputEvent* event) { - if(event->key == InputKeyUp) { - model->up_pressed = false; - } else if(event->key == InputKeyDown) { - model->down_pressed = false; - } else if(event->key == InputKeyLeft) { - model->left_pressed = false; - hid_hal_consumer_key_release(hid_tiktok->hid, HID_CONSUMER_VOLUME_DECREMENT); - } else if(event->key == InputKeyRight) { - model->right_pressed = false; - hid_hal_consumer_key_release(hid_tiktok->hid, HID_CONSUMER_VOLUME_INCREMENT); - } else if(event->key == InputKeyOk) { - model->ok_pressed = false; - } else if(event->key == InputKeyBack) { - model->back_mouse_pressed = false; - } -} - -static bool hid_tiktok_input_callback(InputEvent* event, void* context) { - furi_assert(context); - HidTikTok* hid_tiktok = context; - bool consumed = false; - - with_view_model( - hid_tiktok->view, - HidTikTokModel * model, - { - if(event->type == InputTypePress) { - hid_tiktok_process_press(hid_tiktok, model, event); - if(model->connected && !model->is_cursor_set) { - hid_tiktok_reset_cursor(hid_tiktok); - model->is_cursor_set = true; - } - consumed = true; - } else if(event->type == InputTypeRelease) { - hid_tiktok_process_release(hid_tiktok, model, event); - consumed = true; - } else if(event->type == InputTypeShort) { - if(event->key == InputKeyOk) { - hid_hal_mouse_press(hid_tiktok->hid, HID_MOUSE_BTN_LEFT); - furi_delay_ms(25); - hid_hal_mouse_release(hid_tiktok->hid, HID_MOUSE_BTN_LEFT); - furi_delay_ms(100); - hid_hal_mouse_press(hid_tiktok->hid, HID_MOUSE_BTN_LEFT); - furi_delay_ms(25); - hid_hal_mouse_release(hid_tiktok->hid, HID_MOUSE_BTN_LEFT); - consumed = true; - } else if(event->key == InputKeyDown) { - // Swipe to previous video - hid_hal_mouse_scroll(hid_tiktok->hid, 19); - consumed = true; - } else if(event->key == InputKeyUp) { - // Swipe to new video - hid_hal_mouse_scroll(hid_tiktok->hid, -19); - consumed = true; - } else if(event->key == InputKeyBack) { - // Pause - hid_hal_mouse_press(hid_tiktok->hid, HID_MOUSE_BTN_LEFT); - furi_delay_ms(50); - hid_hal_mouse_release(hid_tiktok->hid, HID_MOUSE_BTN_LEFT); - consumed = true; - } - } else if(event->type == InputTypeLong) { - if(event->key == InputKeyBack) { - hid_hal_consumer_key_release_all(hid_tiktok->hid); - model->is_cursor_set = false; - consumed = false; - } - } - }, - true); - - return consumed; -} - -HidTikTok* hid_tiktok_alloc(Hid* bt_hid) { - HidTikTok* hid_tiktok = malloc(sizeof(HidTikTok)); - hid_tiktok->hid = bt_hid; - hid_tiktok->view = view_alloc(); - view_set_context(hid_tiktok->view, hid_tiktok); - view_allocate_model(hid_tiktok->view, ViewModelTypeLocking, sizeof(HidTikTokModel)); - view_set_draw_callback(hid_tiktok->view, hid_tiktok_draw_callback); - view_set_input_callback(hid_tiktok->view, hid_tiktok_input_callback); - - with_view_model( - hid_tiktok->view, HidTikTokModel * model, { model->transport = bt_hid->transport; }, true); - - return hid_tiktok; -} - -void hid_tiktok_free(HidTikTok* hid_tiktok) { - furi_assert(hid_tiktok); - view_free(hid_tiktok->view); - free(hid_tiktok); -} - -View* hid_tiktok_get_view(HidTikTok* hid_tiktok) { - furi_assert(hid_tiktok); - return hid_tiktok->view; -} - -void hid_tiktok_set_connected_status(HidTikTok* hid_tiktok, bool connected) { - furi_assert(hid_tiktok); - with_view_model( - hid_tiktok->view, - HidTikTokModel * model, - { - model->connected = connected; - model->is_cursor_set = false; - }, - true); -} diff --git a/applications/external/hid_app/views/hid_tiktok.h b/applications/external/hid_app/views/hid_tiktok.h deleted file mode 100644 index b2efc3692d..0000000000 --- a/applications/external/hid_app/views/hid_tiktok.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -typedef struct Hid Hid; -typedef struct HidTikTok HidTikTok; - -HidTikTok* hid_tiktok_alloc(Hid* bt_hid); - -void hid_tiktok_free(HidTikTok* hid_tiktok); - -View* hid_tiktok_get_view(HidTikTok* hid_tiktok); - -void hid_tiktok_set_connected_status(HidTikTok* hid_tiktok, bool connected); diff --git a/applications/external/hid_app/views/hid_ytshorts.h b/applications/external/hid_app/views/hid_ytshorts.h deleted file mode 100644 index 03264dd362..0000000000 --- a/applications/external/hid_app/views/hid_ytshorts.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -typedef struct Hid Hid; -typedef struct HidYTShorts HidYTShorts; - -HidYTShorts* hid_ytshorts_alloc(Hid* bt_hid); - -void hid_ytshorts_free(HidYTShorts* hid_ytshorts); - -View* hid_ytshorts_get_view(HidYTShorts* hid_ytshorts); - -void hid_ytshorts_set_connected_status(HidYTShorts* hid_ytshorts, bool connected); From adb236d8b6e24d6497bc2448bad9ea56b62c2c49 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 27 May 2023 18:38:49 +0300 Subject: [PATCH 87/92] move nfc apps into NFC folder --- applications/external/mfkey32/application.fam | 2 +- applications/external/nfc_magic/application.fam | 2 +- applications/external/picopass/application.fam | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/external/mfkey32/application.fam b/applications/external/mfkey32/application.fam index eb11aec2c0..75fa40bf60 100644 --- a/applications/external/mfkey32/application.fam +++ b/applications/external/mfkey32/application.fam @@ -10,7 +10,7 @@ App( ], stack_size=1 * 1024, fap_icon="mfkey.png", - fap_category="Tools", + fap_category="NFC", fap_author="noproto", fap_icon_assets="images", fap_weburl="https://github.com/noproto/FlipperMfkey", diff --git a/applications/external/nfc_magic/application.fam b/applications/external/nfc_magic/application.fam index db0af81d43..717387d58a 100644 --- a/applications/external/nfc_magic/application.fam +++ b/applications/external/nfc_magic/application.fam @@ -11,7 +11,7 @@ App( stack_size=4 * 1024, order=30, fap_icon="../../../assets/icons/Archive/Nfc_10px.png", - fap_category="Tools", + fap_category="NFC", fap_private_libs=[ Lib( name="magic", diff --git a/applications/external/picopass/application.fam b/applications/external/picopass/application.fam index 387566646d..34c3f785c7 100644 --- a/applications/external/picopass/application.fam +++ b/applications/external/picopass/application.fam @@ -11,7 +11,7 @@ App( stack_size=4 * 1024, order=30, fap_icon="125_10px.png", - fap_category="Tools", + fap_category="NFC", fap_libs=["mbedtls"], fap_private_libs=[ Lib( From 70a7ab7f2e38b61acbeae7697c2b4959ae8eb540 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 27 May 2023 23:55:48 +0300 Subject: [PATCH 88/92] Move mifare nested plugin from extra pack to base fw --- ReadMe.md | 3 + .../external/mifare_nested/LICENSE.md | 674 +++++++ applications/external/mifare_nested/README.md | 38 + applications/external/mifare_nested/TODO.md | 3 + .../external/mifare_nested/application.fam | 25 + .../mifare_nested/assets/ApplyTag.png | Bin 0 -> 3804 bytes .../mifare_nested/assets/DolphinCry.png | Bin 0 -> 3898 bytes .../mifare_nested/assets/DolphinSuccess.png | Bin 0 -> 2681 bytes .../external/mifare_nested/assets/Loading.png | Bin 0 -> 3649 bytes .../external/mifare_nested/assets/icon.png | Bin 0 -> 145 bytes .../mifare_nested/lib/crypto1/crypto1.c | 118 ++ .../mifare_nested/lib/crypto1/crypto1.h | 39 + .../mifare_nested/lib/nested/nested.c | 740 ++++++++ .../mifare_nested/lib/nested/nested.h | 118 ++ .../mifare_nested/lib/parity/parity.c | 71 + .../mifare_nested/lib/parity/parity.h | 10 + .../external/mifare_nested/mifare_nested.c | 408 ++++ .../external/mifare_nested/mifare_nested.h | 3 + .../external/mifare_nested/mifare_nested_i.h | 180 ++ .../mifare_nested/mifare_nested_worker.c | 1663 +++++++++++++++++ .../mifare_nested/mifare_nested_worker.h | 89 + .../mifare_nested/mifare_nested_worker_i.h | 28 + .../scenes/mifare_nested_scene.c | 30 + .../scenes/mifare_nested_scene.h | 29 + .../scenes/mifare_nested_scene_about.c | 77 + .../scenes/mifare_nested_scene_added_keys.c | 76 + .../scenes/mifare_nested_scene_check.c | 102 + .../scenes/mifare_nested_scene_check_keys.c | 124 ++ .../scenes/mifare_nested_scene_collecting.c | 154 ++ .../scenes/mifare_nested_scene_config.h | 13 + .../scenes/mifare_nested_scene_failed.c | 59 + .../mifare_nested_scene_need_collection.c | 56 + .../mifare_nested_scene_need_key_recovery.c | 59 + .../scenes/mifare_nested_scene_no_keys.c | 61 + .../mifare_nested_scene_nonces_collected.c | 58 + .../scenes/mifare_nested_scene_settings.c | 65 + .../scenes/mifare_nested_scene_start.c | 84 + ...fare_nested_scene_static_encrypted_nonce.c | 58 + 38 files changed, 5315 insertions(+) create mode 100644 applications/external/mifare_nested/LICENSE.md create mode 100644 applications/external/mifare_nested/README.md create mode 100644 applications/external/mifare_nested/TODO.md create mode 100644 applications/external/mifare_nested/application.fam create mode 100644 applications/external/mifare_nested/assets/ApplyTag.png create mode 100644 applications/external/mifare_nested/assets/DolphinCry.png create mode 100644 applications/external/mifare_nested/assets/DolphinSuccess.png create mode 100644 applications/external/mifare_nested/assets/Loading.png create mode 100644 applications/external/mifare_nested/assets/icon.png create mode 100644 applications/external/mifare_nested/lib/crypto1/crypto1.c create mode 100644 applications/external/mifare_nested/lib/crypto1/crypto1.h create mode 100644 applications/external/mifare_nested/lib/nested/nested.c create mode 100644 applications/external/mifare_nested/lib/nested/nested.h create mode 100644 applications/external/mifare_nested/lib/parity/parity.c create mode 100644 applications/external/mifare_nested/lib/parity/parity.h create mode 100644 applications/external/mifare_nested/mifare_nested.c create mode 100644 applications/external/mifare_nested/mifare_nested.h create mode 100644 applications/external/mifare_nested/mifare_nested_i.h create mode 100644 applications/external/mifare_nested/mifare_nested_worker.c create mode 100644 applications/external/mifare_nested/mifare_nested_worker.h create mode 100644 applications/external/mifare_nested/mifare_nested_worker_i.h create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene.h create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_about.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_added_keys.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_check.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_check_keys.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_collecting.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_config.h create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_failed.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_need_collection.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_need_key_recovery.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_no_keys.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_nonces_collected.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_settings.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_start.c create mode 100644 applications/external/mifare_nested/scenes/mifare_nested_scene_static_encrypted_nonce.c diff --git a/ReadMe.md b/ReadMe.md index fe6c7fb34b..e25896a23f 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -165,6 +165,7 @@ You can support us by using links or addresses below: - **SWD Probe** [(by g3gg0)](https://github.com/g3gg0/flipper-swd_probe) - IR Scope [(by kallanreed)](https://github.com/DarkFlippers/unleashed-firmware/pull/407) - BadBT plugin (BT version of BadKB) [(by Willy-JL, ClaraCrazy, XFW contributors)](https://github.com/ClaraCrazy/Flipper-Xtreme/tree/dev/applications/main/bad_kb) +- [Flipper (Mifare) Nested (by AloneLiberty)](https://github.com/AloneLiberty/FlipperNested) - Works with PC and python app `FlipperNested` Games: - DOOM (fixed) [(by p4nic4ttack)](https://github.com/p4nic4ttack/doom-flipper-zero/) @@ -193,6 +194,8 @@ Games: ## [- How to change Flipper name](https://github.com/DarkFlippers/unleashed-firmware/blob/dev/documentation/CustomFlipperName.md) +## [- How to use (Mifare) Nested plugin to recover keys](https://github.com/AloneLiberty/FlipperNested#how-to-use-it) + ### **Sub-GHz** ## [- Transmission is blocked? - How to extend Sub-GHz frequency range](https://github.com/DarkFlippers/unleashed-firmware/blob/dev/documentation/DangerousSettings.md) diff --git a/applications/external/mifare_nested/LICENSE.md b/applications/external/mifare_nested/LICENSE.md new file mode 100644 index 0000000000..f288702d2f --- /dev/null +++ b/applications/external/mifare_nested/LICENSE.md @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/applications/external/mifare_nested/README.md b/applications/external/mifare_nested/README.md new file mode 100644 index 0000000000..9d50317258 --- /dev/null +++ b/applications/external/mifare_nested/README.md @@ -0,0 +1,38 @@ +# Mifare Nested Attacks for Flipper Zero + +Ported Nested attacks from Proxmark3 (Iceman fork) + +This is not original Repo of this app! Please follow this link to find latest original source and support the author! +[Flipper (Mifare) Nested (by AloneLiberty)](https://github.com/AloneLiberty/FlipperNested) + +## Currently supported attacks + + - nested attack + - static nested attack + - hard nested attack + +## Warning + +App is still in early development, so there may be bugs. Your Flipper Zero may randomly crash/froze. Please create issue if you find any bugs (one bug = one issue). In original repo! - https://github.com/AloneLiberty/FlipperNested + +## Disclaimer + +The app provided for personal use only. Developer does not take responsibility for any loss or damage caused by the misuse of this app. In addition, the app developer does not guarantee the performance or compatibility of the app with all tags, and cannot be held liable for any damage caused to your tags/Flipper Zero as a result of using the app. By using this app you confirm that the tag belongs to you, you have permission to preform the attack and you agree to hold the app developer harmless from any and all claims, damages, or losses that may arise from its use. + +## I need **your** help! + +To successfuly recover keys from nested attack we need to correctly predict PRNG value. But we have a problem with that. Due to lack of my knowlege of Flipper Zero NFC HAL, PRNG can jump by quite large values (not like Proxmark3). So app is trying to find a delay where PRNG can be predicted accurately enough. This is not the best option, because we have to try to recover a bunch of unnecessary keys, which takes a lot of time and RAM and also spend a lot of time on timings. I don't know how to fix it. + +UPD: Chameleon Ultra devs [faced same issue](https://youtu.be/_wfikmXNQzE?t=202). They seems to use same method: [nested.c](https://github.com/RfidResearchGroup/ChameleonUltra/blob/main/software/src/nested.c) (better know from the beginning of development...) + +## How to use it? + +Detailed guide: [EN](https://github.com/AloneLiberty/FlipperNested/wiki/Usage-guide), [RU](https://github.com/AloneLiberty/FlipperNested/wiki/%D0%93%D0%B0%D0%B9%D0%B4-%D0%BF%D0%BE-%D0%B8%D1%81%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D1%8E). + +## FAQ + +For frequently asked questions, please refer to the FAQ: [EN](https://github.com/AloneLiberty/FlipperNested/wiki/FAQ), [RU](https://github.com/AloneLiberty/FlipperNested/wiki/%D0%A7%D0%90%D0%92%D0%9E). + +## Contacts + +Find here: https://github.com/AloneLiberty/FlipperNested diff --git a/applications/external/mifare_nested/TODO.md b/applications/external/mifare_nested/TODO.md new file mode 100644 index 0000000000..4610e5c7b8 --- /dev/null +++ b/applications/external/mifare_nested/TODO.md @@ -0,0 +1,3 @@ +# TODO: + +1. Better (faster) detection of delay in a nested attack diff --git a/applications/external/mifare_nested/application.fam b/applications/external/mifare_nested/application.fam new file mode 100644 index 0000000000..9bebd9fd83 --- /dev/null +++ b/applications/external/mifare_nested/application.fam @@ -0,0 +1,25 @@ +App( + appid="mifare_nested", + name="Flipper (Mifare) Nested", + apptype=FlipperAppType.EXTERNAL, + entry_point="mifare_nested_app", + requires=[ + "storage", + "gui", + "nfc" + ], + stack_size=4 * 1024, + order=30, + fap_icon="assets/icon.png", + fap_category="NFC", + fap_private_libs=[ + Lib(name="nested"), + Lib(name="parity"), + Lib(name="crypto1") + ], + fap_icon_assets="assets", + fap_author="AloneLiberty", + fap_description="Recover Mifare Classic keys", + fap_weburl="https://github.com/AloneLiberty/FlipperNested", + fap_version=(1, 4) +) diff --git a/applications/external/mifare_nested/assets/ApplyTag.png b/applications/external/mifare_nested/assets/ApplyTag.png new file mode 100644 index 0000000000000000000000000000000000000000..787c0bcfe01755f4dcadcdce004a1a0fcfb06f41 GIT binary patch literal 3804 zcmaJ@c{r5q8h=IhEm=ZpEFm#ttj%O>Gh>M%jEuAmX2zs3V@!>uWXYBy$=*ndeW@t2 zWz8Bw_N_uv;mZActbzR&&K*Zuq5>vLUC)Cn7NA$}Qt004w6El~FC z)qwqJ@p7{N`l=S10KktXBatU8kw_4YP9>5r5&*z=nB_piI?PHUR>zl3ts;Z&T2bvK zctQ52(Lv&I%4+g_qQ@iU9}G#@)$Ku}xnx^1A~|DXf^JIKsSDoVALN;me;5<`DDpeN7EU`+ucxrhC6D_pubb|zQO%LpOAKKj5^kE8Y9L%po14MaC z+~s{X6*+*lKm&s#3bj1101n??0bZaMlUA#_KVnP1pwz;6cv4e>nVV^ z*`kxd_ajB3GivNgr4$>KE5XpgF1#AvJWfvF1FD^tQb)w~@VoG-#^8Ft6ltws9g+7- zZvY@8PJ*57(xz{xa8YNcUQDU*IgKwh+}jGSu9I8SUHLR)0QkTN?A}s`l*j}f;|`*1 zJv=ne<#ARZ8Yu~Z4My)|p^)uC@2|Z@uu>7lF={`q0>EM= zweFoNFK3WP=!Y)m_JYx-dB!0ih-i7o8vxFtl)%`w5~F5b06=8~t35T5U9Q`wUdz3| zZue-Nz{YvK>!wPL^`@ex{O&>f>E{m@gqW&^cRZC-I}dqhET>az=Mf%H69(5iz7$5# zM1JCV)9X~Lg88^iT6p*3<%c6VTyNkMV|b-f!q(*LEV#s?l|ZeL;&uvFak>^z`x{u0 zqlMfeg1!qDaoVgR?pO<;6|xatWe&X?Tx^GUC-?$co}({w-Rz;jTXzODHC8es?JfPe z4C1EVgPFJa9wNiBhR9~k+RyuVv>PvKf}0vlpB+`_i+5{(rcfZ5-z4+&WC3So)QVfz zGbWc-G#v{W#rW1?ch6!T z*j;tdk(RJ2)>Olk_LS_D{Gtm#%hlNX@tVU&Rr|IJ$EBx5r*)>e3CUU}j*n99$8sKE z_vpr+GA(>iYX8J8B4@A8rBql)sHCM;X5qtxUKtN5k5%%M&y0#aV+jXrlHNM?w9lG< zPWsHb%oG#~mk4c+B&kZL?c>=;l4kCEl5CwN-5V|4jMdbKeodZ95lNvs;?zpju1LhS z@h2QlP)?9lgJ5&>vhv3B1RR$f+p)2^XC1BX9m-iIP55E+w+o=4kW9Z6dwaVm8 zxyoonUhV@JQv0~JQ;Gf3U7``sWU}|#J%$b6jB0k$Qs9ko@rA=556fohSeHWyr#OVH)9FF(k)l#c=~X<* zRf<&hx~O43zB>MD#noGz2p*w`A>n+vQ*wbm&*|dulkoA>&U^DlS6?qD&O%7IF43+* z?a9);?S~u5EQhpSbCMLP+$VG?GCImCq#c}O2u_o28f&SZI?h<}KJ&r9XN8qkl2$*L zGxB6!Z=O6KF?#=v&i%vb&e}e28(NU>?WVhp1nwtjdQKDs+9GX(NiSv;A#RX3r^11! zWtq&pRs4dK;SWRl{Yk?~1O0KWap!Yy^lQsn%GzxksOjgzCXm+@x81k>x4VJtphFxa z&ZuCMV3%F%YyMZ{YhsMxBZMEtLvtoKGs;aQOkzU{L#FErm&<@ zoe2Eg|CR^;2_M}MD5w$^5#|(b6hn)|$#g@LbeY|wNS_JRPgEjmJdFgkg+0+YuB&F4 z2fko1tY4v1VblaBI=|_|v2d0bt@gvfYDIcp7hg?m%q>NHWPKEv43J8Ow49;&J?N}o z4$GFz1&gV}6OFASZI0gk!$edqNAl*O#l6f!G5mh@a`hwyNVi^hu2ow(cHrg`$1_)^jr(kJ5O z_5wm!@z!gv=rYKG1fEvUlG_Eloi+GNO|w2@PpJ;5@f4E?PQ;pys5V$)e)^G)xi=+k zBe(VME!^Lp6RQ{daHljg+{#Hq4)>|L-~z1Jz}s(xe^O%ik?@n;1qLr~l&VqsZ1d-w zl8OSWmHjcE!Ds8*Lh4>{czzXdmttMsk?(^LI#&Y*AVh?fl)3`>ui*RCI(x)V0FQK8~=Ry-FpUm{p3MNxUPYl-WWGle!3@405q9?nf3Md8wc@^^i5JqWCQZ2yt3 z=EBVfUv04#m>NQQLXNlYHGNd1q5P(1SNSGZ4+z1BFW(F(_`uV9@Uk394syXXburZ} z%^`K&#nq+4_Kjh8|Ce$94fBzMBKLF*oc)e3VOz<=vmw3lq{XhAtOVB8K=7ZV=SLov z2F$p1PFxV7E>wszKJ=isqi2p)9qT;3_>!?$JTkr4>7`TZ6ZkpG7seNZt@vKs=E{4O zsYT_dJI&$Z>bA$9&sH4XX0OLf$H#ATaV9TqEa=`1 zVc#pI8E72Cfl6dB@pJ-U;!brXfGjC^62YE;clYydC9tocoT_9jj)B8i!`-M9Fn-4d z>`S4s(d-+lkuMGJ=1E|HTnQwy7eZm7vPJ0&f7G$g@;Y~fEQIQZLO-TXb> zVD1V=h9Co9IGcb%VBkT%l#5~DAM z9YVo_!Jxq*5GIoeW@>|}bP@y#gTWx0S`aNQ4Yq}bkDnI<@2lbEqxg#fMeuQ>lW7bx z)eE%4hgD{57v)HfY=j!sF&z&?A{R-cU;lnNIC(}pwh8a>cwA$JmEoQP<=e8G?11y7z$Fw z;N8exJDS6PK`Hnw@Va)7vmS!{XbaPZ?QWAL7}ldqX=~JWrDjIok{`yl{K9F`&jgT z%l9|d{r9ox{}u~j2LsvZ?SJ+9mx?_=JK{gX%ijDm{sb@f%+uM!eS@HLpM5a6PgrBo z+uPf0(XqZakiE=UqD-*9!`~9@gd0J;sFd|{{_$Su6OTiQ@qy}4Oz+SADC0eD@2z)5 z*UNjyq}l<%}`s$yMBoGI9%t(0vZw{+5Rq z$a_i(1-~%{1;=b5oYdU~+8-!0ng8VOVr^*?x?(Qh0upr# zk%V_*qRS%kE5$XlZchN~R+pT^YwQE(4=(Tz+VvKe9OU2z+B$ZHW*CaUXQvEUqHRz` IrsqTc1+$%)k^lez literal 0 HcmV?d00001 diff --git a/applications/external/mifare_nested/assets/DolphinCry.png b/applications/external/mifare_nested/assets/DolphinCry.png new file mode 100644 index 0000000000000000000000000000000000000000..86d9db1b497cd9e49bb62987cb35075b4bc7a410 GIT binary patch literal 3898 zcmbVPcT`hbvp+Nil-@xk1i?Z{LK7mPg%T75LRS$&2oNB}5K0gc3yLC5np6=`L<5$K zf=E+Az)+-$6zL!Wh9bRv;oj?g?~l8__0~IUowH}}J-?aX%$`|mpIbJk&G~qxc>w_6 zvp|`kS>timtI5s5`bs6(^a21c5|2dMSRj!gGKJ)Y_s0Q1NN<*1uyf*yxc=Y@PQcN) zXYNI+{}lkNK<91{bjcOG3t+Ab3LDl%M)5j|iV0<+9BQw2@uIS#Mskjnc^lo1Iuq@1 zPUojwf5EFuq0HIYjV~J&lbMs7EwomF2q9smgo#{VKo=dU2k()Kvqsf6Rz|Rkp@uj? zf)kAQ-duG6Fvmd)38y|c*kpS~0@wj^m)arW`r(~xV~a-v4Qloc zqCkTr@Z9bXPhKDi0Q_lT#$ezHA29RFLZ1uhDNO8_0D5u{6mkPGY(Ux(^F!>0Zvl6Q zD`*w=n)g5s-4LwCSyRjw;qqGDoIRqF3kZsJju$X=2O`ppRhj^h4m*H6DALRUvgF8t zwpR}ox{)KxP;5XABe^;CRJ(>~S@LJ;;Dx!N5&4n#{x6I%5=RBSc*ek)sTm3)s7VgX zmi+)Az1H?_TgM=Na$;`KvB>+i#8p)|a0j+^)F8&It&fZe{kmjgNP8kn7o= z2UhzPo&|ax0iVG&SB*ZNoHM+iL)W5dI-7SW2*rRPDnlH|&h~1ud zzEx%ewyLMSK_{5VHztn=PhD1@mrL2=Net!#=r^ouPQTv!is4@q{*#S8n%}uS2rvv^ zRJ|j;F98tr)>Nmh06=2(TAZOW8_=AZKMDX9-zCpIPLivaf;naK3uZA)Ocz3+&RULfT3A`<<3VCF zHQ5*@_aXM^2$31?^VbF6`(KTZH+QylMm|=YQ792E=XT<`b{+QqFgWqCb%|oA@LFw% z2mD36vl(6Kr~E!L<1d2$b-^OJ;6YT*pVIUn9vH%`lWV%uDp z-O2qV3V#2L1tBNM24Z)!P((8@U9mYs9LdO6&FlJ{j`zl|_&}zpe{d1{d_n0uGOPFj!5}QU6d-2ER}+!Sw7`00)CE+LL|uPaOoFo_Dn;yo$n$ zj`xQ4R`q(!Qf9?xr+b-!N=0lpH*Q?6ZZTOL{77ufnkzXLl>o8npew8TF( z&}P0w_?5RL@q^jTY?C_<)#TQWm-2_{VCS0RvETjf;mg|Qt`9#JV)&FN)cWMLS>zoq zQ~G(+dsHh#Lf?x{I^aRq{D$lI)5Cb+)%)^m^XtZ{jy5OxrF)gPm2^;>ni^F4={@wu znONPfOuuYQ)z^x?&6voCrkQmoqqU>!Q+iXv7+fh8So6o>&HbIMYTa0gh9~}(YT}SN0;n~y|9_h8Qz)nnLV?*%a~=wWx{f+ zY|{Z@+3pk66JZo;U{jDkxneqhSo1?+ZQ+M0CvO?=2LV}&S`v>=#WRFcgHk2z2nDwb zi1$Mo$>Y*L%iCXdEahdq&FC-sO6VMDLeyP)x?!c3A=Bvk0l_r-HMinCa-nH7t01G` z{bKwiQB^u*p}E)FHl!hy6Iys8{U<%^KpfD-kj+3eN74S zru+J%{joC{Wf5gh%C3amTs56f6{dhv`J#6Ha|;Fn$eWYy*+B9xotT$%-so&xo`(t;&tbwS7@qc2e)| zM3!Unvd+MXOUQMf8`frlA2oQa(aN+0sk?6!7Ofmjy1&s|zh3yNs+*LVl$nR-!>5!e ze}R@BDYf=eR!-y_qfHP#$t2$Vv@)i!7O>bS<{xROh>dhfI0(MEF3Nd9Za|cHG5>7xylkGN*m1B>(T}>P<@GQvA zI&FaHOzWquSZ=2Ix!Sr`dLvu24J4>PElb^28W+D!#<|W_kbi+!Jo*$%PZc4G5$56K ztzp!&v!rR<3S-tuubBGFYWhSQv*Yr*Z%tRgm(?$7uJ>t`%#SlNr9`EH17(WkORGW4 zvl79)KP~%RL*qi8ZC3Se{n)!M@Z)mH_6uAMVQAI8#=Z4}ivW|K=VtbH(oVBg6h0Xo&eon?)^smzZVD^1=E_xwIpjhTAraZR^%owTf=R%9g32agJ+;Os(A z+harhu)3aL1AUNQ2%KerfTLnSAq0P706YW%{?jg;CGRdnz@R@>sD23WU!2{qO$ba=6$*uG=)yHML4QABmOF~47aVP3 z_O~VnS4j0Sdn@nBW4i z6g-)VClNur7BL>AKq>;vqWV`11hSRYKZc0`e`ku7Ge`)A41uXZAq2v1V1H@{P|>*m zq4BTU0roU94uZx7kOC=K)`55_{06g<_un1uDzezXttqVQ0}vll+s?n?O?6F>+R)=B zFb$**3}%Wn)>7BjHPMFYXdsPE%(QiXV=agQR16V|`|TUg^8Gg!`CqYcBn5||k|_2h zlK<~Au<;>LNdZ12GDuxrO$&6y3WLQHcUO+?p3+}Io8Tz;Ae^Teg+u`TnPxctUnuWKDPU{wCBG_`5^SrDXDDWsPryOAx% z8Qb*4J4V#bug_E`4$vj4JhIE)WvY#0Z6=Ogt`Q3w6`1fCi~DkUb-dj(=?%y0vCrfm zJnG7Iw>w1ai@*ZiKV0Jrg(|w1gpw{4q0d<=?Kun`O-ejQ8A;&nJdlp?YKe)^eww~& z_*RZrH{)=4+|xO8-gQRoLv%;cVVY;>^Y2M>G z(a!3bBGF5=Y(^HJrB5bl&MKyioPiO$t#$z|5-p5%+bKGa;Q<3yE5Ey~* zc}h_2EeK@k(||b6!2mKb0?`P90fa(~%5YqU!~htAAuu9^Q4B(5B!ZJD0r)`AD7TI{p4cVOGV+>lxNjq3O z&vG`v%Saix0$vFUN=KJqwU5)CWtj)-|oKapyz6p$$;u$3aUm19L{!RP-!Ry`D_8IeE%PGl^OyD2NiXtdW#63}s*l z1!SZo6hupL8ZyWcDI_5lb-=g@OT!CeUm7-`bPIjoeBAJ$5l8Q5+!d($ki3w0A% zr_j10-}AAQ$@h&cEHDx}lA^s?SAw*+$&3;7-DaQQ-m~c(rFG>p0_jtlKMHelCf-Fk z7`0h&`hSKC{yFhZs_^O3pRMu#N9jIW>0HWYW`vCs2EB`cy<5y^Q{eyZ*Q0)qWkxNe z+1pL0&jt-;9ydhwaaFfD_;RXU5RbgQtag7C2 zhiG(KOrnS*)EX4kX*7sj5~q_a#t}rJi_^#+n>n(QQ9*%bx71r}g zOh?Nr0V%D+vkjR^-L8r$uG*D%=0_JstSCthwRNIZ6UzYqsFat{*<}NghoNb+7R7YN z^|kN%>y`Lk?$*NL`?8^w53Bq;UQ8~MR$yhHIfmNh{(!hK6YktHA^)}ZHQ^PW@~*Xfnv zyN6~6#V@*a?tRU-Y)Q5wKX~|}3?sI6m4^BC_BFJqEC)q%r`~OT$$YnRQ_CMZ2ENIB zSl)B!q*-I%{>kmC9VctbLQkruy?m74mCYagwq{Ri;J}Z7JbcyMg8I~c&%6ipv48H( zZR>5U8+0X?JC_bM#2pJOxZWB#J^jn?bJfX{FIk83{d9;cX7x>YYDnoE^-aUI8}RgZ zIBn9citKF!AINLkL^rrTGK91fqwf0=~Vsi8CK5AM0vh)#dnRC#A`T7`eDX;tPYB~dd1 zep=o%u`*1)tI*R@76D5xM*-QB#zTG=7j%O3(`FIAIS2uN{Aln&F@9)?Dgd} zcc|l&fZy&dy)n6`u6{#l>hr|5n%Cp|4{!DxI2g=S9N<1rj_Ukn(c0 zH*)b`%3H3s_r2=MII*qfW8LLsxV-L~J2pzaJNj2i-vtbLR7>;!-db4@Os~B@@7zkZ zXT=LO^0)h?M_*gE=d1MHA9+sji=XqXuRWFCB`NV>4_bG+XE!Au&4Dh5v>)+5xA%Q< zt!wkCD*1qFcbm2QU-Ns4j%yP)AGv=iHmi5LIIl#~eyjM6MEh_+V&0tvJ5=S=dJOTy~%6^nwZGp5xyf1Iy3Yx}id-~MjWmBzE@l0x=}tLFY`$&$eh z_Sk*5-$8R4Q+~K zs}!Vu|T0fG&^kldAlcBl>S5JG204rZ&Cc^O@cJQ3w^Qg>RR zx8UiyV9wOk>ZjF;v5c{`7FO%duw7y*@uRsu02~{khv-s>wL#Z5REF_NqWk$lqN9zk zytcdnfEhj(GnDbrV2$Si72pME9UA+@>IQyYEXSxg0ibxGA1pSuohJ?p)N9z+O91t| zfroZaJcNKm0Ptg-H3kFsgn`K)7W!L&uEK;~X`m~2PoV%1%>$&Wn(yN^d;z#QT)?XF z*1Q6;*@j>Z{+eQ*Fz075bKbDZEkIxlE^eox8xWRitkwj8ba?^PUh!r=kR@L>w7t5& z@H8!=49x@7G$u8t9BC`)=T8#Fi5Kd3nP%I}deUiyHjr{FL+BPCr)96iQo*|Gxw zWS84sZs;1sjg1ZujCzjwaelnX-SC~Eg7p<=`!*`B^YR0t)~%fG(<39De6%{AhXK{T zg)Tt1BjDY)?5foxn0-R%eeiM=OLxt1Z&nVbUQd3H(Dv<9%I-Op(4i>(Us?my{;1GJ z?(RlU@Cl;(z*(Pd0m3+JI=uOHEzjv3{|W7ba-Z zTiteNz1m%IS&-kTUO*hLh=|>6`(r_iNryc~mwsx(;Tr=^)V_UwDya9&K?<&Y%dzv6_Jb4d+LR~!ZNE zNW`rZ7Ub+e48-nAp}2NHnsRfx6sj>_J+I?^8p(^a z6H7uQIVOcBjoq_%@OLoiVBOnpf8Sx}{Zo$T?wC0|!3-4&ew4c3Q7G^5qVRBW3pNNF zi)pnzomX{wJ$!{A{P=Q&S@vago;{)TtxU9{)LR&F7H8Z^cjTK;^Sx>1?(%qf(lT(% zs$3u>#L^Dsf6tTc8Sj}ndZw92F=CQPMg9JsJ6i2I2k`pUBXOL9O0YqO;TCg%%y?5yBfXA<7>V1+AQ++m#Iu& z@fy-$O6z;Fse9bn+FyyizIu3f609e`Hvi3V)q&Q(#uliikvlbn3+ce|Nv8cmQb;;eyXB)R9TO}{CZ#wEbvK$v2Kd~)3Pfn;!kUO3H zFmg`mJJJ#9jnD2Dr5Du(rjz?51|?z-v>#ZoqjYOdu1yL}rcG|0f-mA1l^4m2t@2HK z#N<1VGLD|5GXk0d{b&^v`2*Uo3u_Bsk2`tEdFA+L&g)3uIUd(2mJ*mEZAUJ+RzSHG z+?X^XJ6+!X^ut14`iu15qR-@yUz(6_&fQ#;wp2Uv4bv({VOcwX|1@Kj!qz3_z3mrsE|mH+lOoh{K@UTlTz z(3dpcAt>yuKu@67NYBYF6SR80)Y94{-w9+&o{(FCHmO+d?c5b}xmBP~G?aR0*>b$; znLuQ}xnE?N0!b!Sdik8hfrGGn8sBY8>=M!t2kE_V_%b2YRu6 z{IGt6$@H?YvU_D0m{)$9&ZdYl#PWw&h?FJd?jfejZWm@5x)Ocj zqgJ2i#`k5V?cq{qE8`ww${s%HDq}j&_JgZUUq~rM*+~a!Xu4v{J(#4K_H&KijgOPp zF@rd)!<-MRcP<8dvHkXK)S+-E?WDrQhDJ*9j}y-clK3PK2aZolhl}I+gVIT-*);au z;-3%A%0>sBtWS5GU0{*ByT2YQeK$3Mp2(k|u$P>x9~`UnG3t1Kc}BQMZZ>*E?lk$> zS4K{-&q7RdN%OmAJ{`QyluOeycF$bS;k?D*%=4~|j_XDDORGMsbaz&N2@07PxhOAr z^eZQEvf}9>rju`_>A3|;`*ir1SXp{-d09!qeoQ=$>xS13nwh!9Yx6YG?fovDhPT^Z^Wi45*rTV(sx>kCjTC)tK8Pk@fr;6aM$d`ql?mkGJC1x@NX7N3~WLvkK?w zoco0j5Oqp*3KcCZoH9;%UtOg_s_L5I24=o(g-}=U-eyUE?Ci!GWa-lU zY8YI37x%AHhGB|h*ik(hL3lb5F!G?f6G0YaycZEm#Cx#LG!XRwfKQcVk7MAhED;1M zSp&c6qroK8xM%>-Ghov21YaTp+3>pFg2?`3*2-4D^(!C&>a5x+Sg+X92b*_iHKa0Y^Gu0{nO1~LQi2ejR ziN+vNDWFY8ygN03fdq4t{r4%zw0~$R{(o1BTQdj~PlIS`KsQhI+tJGE|GSdO|9JZ| zu*Co5`#*{O?O8M;1WWX%2G9xI-gzo*hN2-*bRwQXrQ1`fe!mNe@uo7U{@zp?2&Sc> z1yZ%b6G)Uz%YnZjR#pfLia!HSArLK0kYFx}28rZ>(AGYzWd?^Do9aN1Xlk0GjEr@( zOwCY7bYYq>xRw_DH`ato2p|(FjNe#~|6oyn#BK_LOyfp2A<{{KL=Q7Ml??jp)Ckg_ zbAkVn?{BQfpK~$#BNoC<2C~`P|LXN`6IVc+(|^RvUHl_|B897YI#=9}_AkY9FUD4k zrM>B|@Xb4NEn;?-J6Kzo7}+zs^RX^M07#%``usTPM&dJQT7TW0pZvvcreZ!fk89eR zxb$l$y&OrR&%MN0k$&Et1-(znrXGup@9h&S%{ikQa$ LTALIbyM_M?u*zuP literal 0 HcmV?d00001 diff --git a/applications/external/mifare_nested/assets/icon.png b/applications/external/mifare_nested/assets/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ae72f2ff98a5afd218ea0fd2d87ab7d519a4d441 GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4aTa()7Beu23xP0W`us~ERnDF+ zjv*3Ld;2}P7z{X$SRMUeZ)v+#RQ$qZCz-_z*A{G(SD9MNq`iQ(QONH>>*b{{jm7rv ovhB{BD*r)NpJ7kPe7iCmVLuhF#>KZz1C3+wboFyt=akR{01})k(*OVf literal 0 HcmV?d00001 diff --git a/applications/external/mifare_nested/lib/crypto1/crypto1.c b/applications/external/mifare_nested/lib/crypto1/crypto1.c new file mode 100644 index 0000000000..0483f45e8e --- /dev/null +++ b/applications/external/mifare_nested/lib/crypto1/crypto1.c @@ -0,0 +1,118 @@ +#include "crypto1.h" +#include + +void crypto1_reset(Crypto1* crypto1) { + furi_assert(crypto1); + crypto1->even = 0; + crypto1->odd = 0; +} + +void crypto1_init(Crypto1* crypto1, uint64_t key) { + furi_assert(crypto1); + crypto1->even = 0; + crypto1->odd = 0; + for(int8_t i = 47; i > 0; i -= 2) { + crypto1->odd = crypto1->odd << 1 | FURI_BIT(key, (i - 1) ^ 7); + crypto1->even = crypto1->even << 1 | FURI_BIT(key, i ^ 7); + } +} + +uint32_t crypto1_filter(uint32_t in) { + uint32_t out = 0; + out = 0xf22c0 >> (in & 0xf) & 16; + out |= 0x6c9c0 >> (in >> 4 & 0xf) & 8; + out |= 0x3c8b0 >> (in >> 8 & 0xf) & 4; + out |= 0x1e458 >> (in >> 12 & 0xf) & 2; + out |= 0x0d938 >> (in >> 16 & 0xf) & 1; + return FURI_BIT(0xEC57E80A, out); +} + +uint8_t crypto1_bit(Crypto1* crypto1, uint8_t in, int is_encrypted) { + furi_assert(crypto1); + uint8_t out = crypto1_filter(crypto1->odd); + uint32_t feed = out & (!!is_encrypted); + feed ^= !!in; + feed ^= LF_POLY_ODD & crypto1->odd; + feed ^= LF_POLY_EVEN & crypto1->even; + crypto1->even = crypto1->even << 1 | (evenparity32(feed)); + + FURI_SWAP(crypto1->odd, crypto1->even); + return out; +} + +uint8_t crypto1_byte(Crypto1* crypto1, uint8_t in, int is_encrypted) { + furi_assert(crypto1); + uint8_t out = 0; + for(uint8_t i = 0; i < 8; i++) { + out |= crypto1_bit(crypto1, FURI_BIT(in, i), is_encrypted) << i; + } + return out; +} + +uint32_t crypto1_word(Crypto1* crypto1, uint32_t in, int is_encrypted) { + furi_assert(crypto1); + uint32_t out = 0; + for(uint8_t i = 0; i < 32; i++) { + out |= (uint32_t)crypto1_bit(crypto1, BEBIT(in, i), is_encrypted) << (24 ^ i); + } + return out; +} + +uint32_t prng_successor(uint32_t x, uint32_t n) { + SWAPENDIAN(x); + while(n--) x = x >> 1 | (x >> 16 ^ x >> 18 ^ x >> 19 ^ x >> 21) << 31; + + return SWAPENDIAN(x); +} + +void crypto1_decrypt( + Crypto1* crypto, + uint8_t* encrypted_data, + uint16_t encrypted_data_bits, + uint8_t* decrypted_data) { + furi_assert(crypto); + furi_assert(encrypted_data); + furi_assert(decrypted_data); + + if(encrypted_data_bits < 8) { + uint8_t decrypted_byte = 0; + decrypted_byte |= (crypto1_bit(crypto, 0, 0) ^ FURI_BIT(encrypted_data[0], 0)) << 0; + decrypted_byte |= (crypto1_bit(crypto, 0, 0) ^ FURI_BIT(encrypted_data[0], 1)) << 1; + decrypted_byte |= (crypto1_bit(crypto, 0, 0) ^ FURI_BIT(encrypted_data[0], 2)) << 2; + decrypted_byte |= (crypto1_bit(crypto, 0, 0) ^ FURI_BIT(encrypted_data[0], 3)) << 3; + decrypted_data[0] = decrypted_byte; + } else { + for(size_t i = 0; i < encrypted_data_bits / 8; i++) { + decrypted_data[i] = crypto1_byte(crypto, 0, 0) ^ encrypted_data[i]; + } + } +} + +void crypto1_encrypt( + Crypto1* crypto, + uint8_t* keystream, + uint8_t* plain_data, + uint16_t plain_data_bits, + uint8_t* encrypted_data, + uint8_t* encrypted_parity) { + furi_assert(crypto); + furi_assert(plain_data); + furi_assert(encrypted_data); + furi_assert(encrypted_parity); + + if(plain_data_bits < 8) { + encrypted_data[0] = 0; + for(size_t i = 0; i < plain_data_bits; i++) { + encrypted_data[0] |= (crypto1_bit(crypto, 0, 0) ^ FURI_BIT(plain_data[0], i)) << i; + } + } else { + memset(encrypted_parity, 0, plain_data_bits / 8 + 1); + for(uint8_t i = 0; i < plain_data_bits / 8; i++) { + encrypted_data[i] = crypto1_byte(crypto, keystream ? keystream[i] : 0, 0) ^ + plain_data[i]; + encrypted_parity[i / 8] |= + (((crypto1_filter(crypto->odd) ^ oddparity8(plain_data[i])) & 0x01) + << (7 - (i & 0x0007))); + } + } +} \ No newline at end of file diff --git a/applications/external/mifare_nested/lib/crypto1/crypto1.h b/applications/external/mifare_nested/lib/crypto1/crypto1.h new file mode 100644 index 0000000000..bad6e631b6 --- /dev/null +++ b/applications/external/mifare_nested/lib/crypto1/crypto1.h @@ -0,0 +1,39 @@ +#include "../../lib/parity/parity.h" +#include +#include +#include "stddef.h" + +#define LF_POLY_ODD (0x29CE5C) +#define LF_POLY_EVEN (0x870804) + +#define SWAPENDIAN(x) \ + ((x) = ((x) >> 8 & 0xff00ff) | ((x)&0xff00ff) << 8, (x) = (x) >> 16 | (x) << 16) +#define BEBIT(x, n) FURI_BIT(x, (n) ^ 24) + +void crypto1_reset(Crypto1* crypto1); + +void crypto1_init(Crypto1* crypto1, uint64_t key); + +uint32_t crypto1_filter(uint32_t in); + +uint8_t crypto1_bit(Crypto1* crypto1, uint8_t in, int is_encrypted); + +uint8_t crypto1_byte(Crypto1* crypto1, uint8_t in, int is_encrypted); + +uint32_t crypto1_word(Crypto1* crypto1, uint32_t in, int is_encrypted); + +uint32_t prng_successor(uint32_t x, uint32_t n); + +void crypto1_decrypt( + Crypto1* crypto, + uint8_t* encrypted_data, + uint16_t encrypted_data_bits, + uint8_t* decrypted_data); + +void crypto1_encrypt( + Crypto1* crypto, + uint8_t* keystream, + uint8_t* plain_data, + uint16_t plain_data_bits, + uint8_t* encrypted_data, + uint8_t* encrypted_parity); \ No newline at end of file diff --git a/applications/external/mifare_nested/lib/nested/nested.c b/applications/external/mifare_nested/lib/nested/nested.c new file mode 100644 index 0000000000..4d04b99d54 --- /dev/null +++ b/applications/external/mifare_nested/lib/nested/nested.c @@ -0,0 +1,740 @@ +#include "nested.h" + +#include +#include "../../lib/parity/parity.h" +#include "../../lib/crypto1/crypto1.h" +#define TAG "Nested" + +void nfc_util_num2bytes(uint64_t src, uint8_t len, uint8_t* dest) { + furi_assert(dest); + furi_assert(len <= 8); + + while(len--) { + dest[len] = (uint8_t)src; + src >>= 8; + } +} + +uint64_t nfc_util_bytes2num(const uint8_t* src, uint8_t len) { + furi_assert(src); + furi_assert(len <= 8); + + uint64_t res = 0; + while(len--) { + res = (res << 8) | (*src); + src++; + } + return res; +} + +uint16_t nfca_get_crc16(uint8_t* buff, uint16_t len) { + uint16_t crc = 0x6363; // NFCA_CRC_INIT + uint8_t byte = 0; + + for(uint8_t i = 0; i < len; i++) { + byte = buff[i]; + byte ^= (uint8_t)(crc & 0xff); + byte ^= byte << 4; + crc = (crc >> 8) ^ (((uint16_t)byte) << 8) ^ (((uint16_t)byte) << 3) ^ + (((uint16_t)byte) >> 4); + } + + return crc; +} + +void nfca_append_crc16(uint8_t* buff, uint16_t len) { + uint16_t crc = nfca_get_crc16(buff, len); + buff[len] = (uint8_t)crc; + buff[len + 1] = (uint8_t)(crc >> 8); +} + +bool mifare_sendcmd_short( + Crypto1* crypto, + FuriHalNfcTxRxContext* tx_rx, + bool crypted, + uint32_t cmd, + uint32_t data) { + uint16_t pos; + uint8_t dcmd[4] = {cmd, data, 0x00, 0x00}; + nfca_append_crc16(dcmd, 2); + + memset(tx_rx->tx_data, 0, sizeof(tx_rx->tx_data)); + memset(tx_rx->tx_parity, 0, sizeof(tx_rx->tx_parity)); + + if(crypted) { + for(pos = 0; pos < 4; pos++) { + uint8_t res = crypto1_byte(crypto, 0x00, 0) ^ dcmd[pos]; + tx_rx->tx_data[pos] = res; + tx_rx->tx_parity[0] |= + (((crypto1_filter(crypto->odd) ^ oddparity8(dcmd[pos])) & 0x01) << (7 - pos)); + } + + tx_rx->tx_rx_type = FuriHalNfcTxRxTypeRaw; + tx_rx->tx_bits = 4 * 8; + } else { + for(pos = 0; pos < 2; pos++) { + tx_rx->tx_data[pos] = dcmd[pos]; + } + + tx_rx->tx_rx_type = FuriHalNfcTxRxTypeRxNoCrc; + tx_rx->tx_bits = 2 * 8; + } + + if(!furi_hal_nfc_tx_rx(tx_rx, 6)) return false; + + return true; +} + +bool mifare_classic_authex( + Crypto1* crypto, + FuriHalNfcTxRxContext* tx_rx, + uint32_t uid, + uint32_t blockNo, + uint32_t keyType, + uint64_t ui64Key, + bool isNested, + uint32_t* ntptr) { + uint32_t nt, ntpp; // Supplied tag nonce + uint8_t nr[4]; + + // "random" reader nonce: + nfc_util_num2bytes(prng_successor(0, 32), 4, nr); // DWT->CYCCNT + + // Transmit MIFARE_CLASSIC_AUTH + if(!mifare_sendcmd_short(crypto, tx_rx, isNested, 0x60 + (keyType & 0x01), blockNo)) { + return false; + }; + + memset(tx_rx->tx_data, 0, sizeof(tx_rx->tx_data)); + memset(tx_rx->tx_parity, 0, sizeof(tx_rx->tx_parity)); + + nt = (uint32_t)nfc_util_bytes2num(tx_rx->rx_data, 4); + + if(isNested) crypto1_reset(crypto); // deinit + + crypto1_init(crypto, ui64Key); + + if(isNested) { + nt = crypto1_word(crypto, nt ^ uid, 1) ^ nt; + } else { + crypto1_word(crypto, nt ^ uid, 0); + } + + // save Nt + if(ntptr) *ntptr = nt; + + // Generate (encrypted) nr+parity by loading it into the cipher (Nr) + tx_rx->tx_parity[0] = 0; + for(uint8_t i = 0; i < 4; i++) { + tx_rx->tx_data[i] = crypto1_byte(crypto, nr[i], 0) ^ nr[i]; + tx_rx->tx_parity[0] |= + (((crypto1_filter(crypto->odd) ^ oddparity8(nr[i])) & 0x01) << (7 - i)); + } + + nt = prng_successor(nt, 32); + + for(uint8_t i = 4; i < 8; i++) { + nt = prng_successor(nt, 8); + tx_rx->tx_data[i] = crypto1_byte(crypto, 0x00, 0) ^ (nt & 0xff); + tx_rx->tx_parity[0] |= + (((crypto1_filter(crypto->odd) ^ oddparity8(nt & 0xff)) & 0x01) << (7 - i)); + } + + tx_rx->tx_rx_type = FuriHalNfcTxRxTypeRaw; + tx_rx->tx_bits = 8 * 8; + + if(!furi_hal_nfc_tx_rx(tx_rx, 25)) { + return false; + }; + + uint32_t answer = (uint32_t)nfc_util_bytes2num(tx_rx->rx_data, 4); + + ntpp = prng_successor(nt, 32) ^ crypto1_word(crypto, 0, 0); + + if(answer != ntpp) { + return false; + } + + return true; +} + +static int valid_nonce(uint32_t Nt, uint32_t NtEnc, uint32_t Ks1, const uint8_t* parity) { + return ((oddparity8((Nt >> 24) & 0xFF) == + ((parity[0]) ^ oddparity8((NtEnc >> 24) & 0xFF) ^ FURI_BIT(Ks1, 16))) && + (oddparity8((Nt >> 16) & 0xFF) == + ((parity[1]) ^ oddparity8((NtEnc >> 16) & 0xFF) ^ FURI_BIT(Ks1, 8))) && + (oddparity8((Nt >> 8) & 0xFF) == + ((parity[2]) ^ oddparity8((NtEnc >> 8) & 0xFF) ^ FURI_BIT(Ks1, 0)))) ? + 1 : + 0; +} + +void nonce_distance(uint32_t* msb, uint32_t* lsb) { + uint16_t x = 1, pos; + uint8_t calc_ok = 0; + + for(uint16_t i = 1; i; ++i) { + pos = (x & 0xff) << 8 | x >> 8; + + if((pos == *msb) & !(calc_ok >> 0 & 0x01)) { + *msb = i; + calc_ok |= 0x01; + } + + if((pos == *lsb) & !(calc_ok >> 1 & 0x01)) { + *lsb = i; + calc_ok |= 0x02; + } + + if(calc_ok == 0x03) { + return; + } + + x = x >> 1 | (x ^ x >> 2 ^ x >> 3 ^ x >> 5) << 15; + } +} + +bool validate_prng_nonce(uint32_t nonce) { + uint32_t msb = nonce >> 16; + uint32_t lsb = nonce & 0xffff; + nonce_distance(&msb, &lsb); + return ((65535 - msb + lsb) % 65535) == 16; +} + +MifareNestedNonceType nested_check_nonce_type(FuriHalNfcTxRxContext* tx_rx, uint8_t blockNo) { + uint32_t nonces[5] = {}; + uint8_t sameNonces = 0; + uint8_t hardNonces = 0; + Crypto1 crypt; + Crypto1* crypto = {&crypt}; + + for(int32_t i = 0; i < 5; i++) { + // Setup nfc poller + nfc_activate(); + furi_hal_nfc_activate_nfca(100, NULL); + + // Start communication + bool success = mifare_sendcmd_short(crypto, tx_rx, false, 0x60, blockNo); + if(!success) { + continue; + }; + + uint32_t nt = (uint32_t)nfc_util_bytes2num(tx_rx->rx_data, 4); + if(nt == 0) continue; + if(!validate_prng_nonce(nt)) hardNonces++; + nonces[i] = nt; + + nfc_deactivate(); + } + + for(int32_t i = 0; i < 5; i++) { + for(int32_t j = 0; j < 5; j++) { + if(i != j && nonces[j] && nonces[i] == nonces[j]) { + sameNonces++; + } + } + } + + if(!nonces[4]) { + return MifareNestedNonceNoTag; + } + + if(sameNonces > 3) { + return MifareNestedNonceStatic; + } + + if(hardNonces > 3) { + return MifareNestedNonceHard; + } + + return MifareNestedNonceWeak; +} + +struct nonce_info_static nested_static_nonce_attack( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint8_t targetBlockNo, + uint8_t targetKeyType, + uint64_t ui64Key) { + uint32_t cuid = 0; + Crypto1* crypto = malloc(sizeof(Crypto1)); + struct nonce_info_static r; + + r.full = false; + + // Setup nfc poller + nfc_activate(); + if(!furi_hal_nfc_activate_nfca(200, &cuid)) { + free(crypto); + return r; + } + + r.cuid = cuid; + + uint32_t nt1; + uint32_t nt_unused; + + crypto1_reset(crypto); + + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, &nt1); + + if(targetKeyType == 1 && nt1 == 0x009080A2) { + r.target_nt[0] = prng_successor(nt1, 161); + r.target_nt[1] = prng_successor(nt1, 321); + } else { + r.target_nt[0] = prng_successor(nt1, 160); + r.target_nt[1] = prng_successor(nt1, 320); + } + + bool success = + mifare_sendcmd_short(crypto, tx_rx, true, 0x60 + (targetKeyType & 0x01), targetBlockNo); + + if(!success) { + free(crypto); + return r; + }; + + uint32_t nt2 = nfc_util_bytes2num(tx_rx->rx_data, 4); + r.target_ks[0] = nt2 ^ r.target_nt[0]; + + nfc_activate(); + + if(!furi_hal_nfc_activate_nfca(200, &cuid)) { + free(crypto); + return r; + } + + crypto1_reset(crypto); + + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, &nt1); + + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, true, &nt_unused); + + success = + mifare_sendcmd_short(crypto, tx_rx, true, 0x60 + (targetKeyType & 0x01), targetBlockNo); + + free(crypto); + + if(!success) { + return r; + }; + + uint32_t nt3 = (uint32_t)nfc_util_bytes2num(tx_rx->rx_data, 4); + + r.target_ks[1] = nt3 ^ r.target_nt[1]; + r.full = true; + + nfc_deactivate(); + + return r; +} + +uint32_t nested_calibrate_distance( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint64_t ui64Key, + uint32_t delay, + bool full) { + uint32_t cuid = 0; + Crypto1* crypto = malloc(sizeof(Crypto1)); + uint32_t nt1, nt2, i = 0, davg = 0, dmin = 0, dmax = 0, rtr = 0, unsuccessful_tries = 0; + uint32_t max_prng_value = full ? 65565 : 1200; + uint32_t rounds = full ? 5 : 17; // full does not require precision + uint32_t collected = 0; + + for(rtr = 0; rtr < rounds; rtr++) { + nfc_activate(); + if(!furi_hal_nfc_activate_nfca(200, &cuid)) break; + + if(!mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, &nt1)) { + continue; + } + + furi_delay_us(delay); + + if(!mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, true, &nt2)) { + continue; + } + + // NXP Mifare is typical around 840, but for some unlicensed/compatible mifare tag this can be 160 + uint32_t nttmp = prng_successor(nt1, 100); + + for(i = 101; i < max_prng_value; i++) { + nttmp = prng_successor(nttmp, 1); + if(nttmp == nt2) break; + } + + if(i != max_prng_value) { + if(rtr != 0) { + davg += i; + dmin = MIN(dmin, i); + dmax = MAX(dmax, i); + } else { + dmin = dmax = i; + } + + FURI_LOG_D(TAG, "Calibrating: ntdist=%lu", i); + collected++; + } else { + unsuccessful_tries++; + if(unsuccessful_tries > 12) { + free(crypto); + FURI_LOG_E( + TAG, + "Tag isn't vulnerable to nested attack (random numbers are not predictable)"); + return 0; + } + } + } + + if(collected > 1) davg = (davg + (collected - 1) / 2) / (collected - 1); + + davg = MIN(MAX(dmin, davg), dmax); + + FURI_LOG_I( + TAG, + "Calibration completed: rtr=%lu min=%lu max=%lu avg=%lu collected=%lu", + rtr, + dmin, + dmax, + davg, + collected); + + free(crypto); + + nfc_deactivate(); + + return davg; +} + +struct distance_info nested_calibrate_distance_info( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint64_t ui64Key) { + uint32_t cuid = 0; + Crypto1* crypto = malloc(sizeof(Crypto1)); + uint32_t nt1, nt2, i = 0, davg = 0, dmin = 0, dmax = 0, rtr = 0, unsuccessful_tries = 0; + struct distance_info r; + r.min_prng = 0; + r.max_prng = 0; + r.mid_prng = 0; + + for(rtr = 0; rtr < 10; rtr++) { + nfc_activate(); + if(!furi_hal_nfc_activate_nfca(200, &cuid)) break; + + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, &nt1); + + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, true, &nt2); + + // NXP Mifare is typical around 840, but for some unlicensed/compatible mifare tag this can be 160 + uint32_t nttmp = prng_successor(nt1, 1); + + for(i = 2; i < 65565; i++) { + nttmp = prng_successor(nttmp, 1); + if(nttmp == nt2) break; + } + + if(i != 65565) { + if(rtr != 0) { + davg += i; + if(dmin == 0) { + dmin = i; + } else { + dmin = MIN(dmin, i); + } + dmax = MAX(dmax, i); + } + + FURI_LOG_D(TAG, "Calibrating: ntdist=%lu", i); + } else { + unsuccessful_tries++; + if(unsuccessful_tries > 12) { + free(crypto); + + FURI_LOG_E( + TAG, + "Tag isn't vulnerable to nested attack (random numbers are not predictable)"); + + return r; + } + } + } + + if(rtr > 1) davg = (davg + (rtr - 1) / 2) / (rtr - 1); + + FURI_LOG_I( + TAG, "Calibration completed: rtr=%lu min=%lu max=%lu avg=%lu", rtr, dmin, dmax, davg); + + r.min_prng = dmin; + r.max_prng = dmax; + r.mid_prng = davg; + + free(crypto); + + nfc_deactivate(); + + return r; +} + +struct nonce_info nested_attack( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint8_t targetBlockNo, + uint8_t targetKeyType, + uint64_t ui64Key, + uint32_t distance, + uint32_t delay) { + uint32_t cuid = 0; + Crypto1* crypto = malloc(sizeof(Crypto1)); + uint8_t par_array[4] = {0x00}; + uint32_t nt1, nt2, ks1, i = 0, j = 0; + struct nonce_info r; + uint32_t dmin = distance - 2; + uint32_t dmax = distance + 2; + + r.full = false; + + for(i = 0; i < 2; i++) { // look for exactly two different nonces + r.target_nt[i] = 0; + + while(r.target_nt[i] == 0) { // continue until we have an unambiguous nonce + nfc_activate(); + if(!furi_hal_nfc_activate_nfca(200, &cuid)) { + free(crypto); + return r; + } + + r.cuid = cuid; + + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, &nt1); + + furi_delay_us(delay); + + bool success = mifare_sendcmd_short( + crypto, tx_rx, true, 0x60 + (targetKeyType & 0x01), targetBlockNo); + + if(!success) continue; + + nt2 = nfc_util_bytes2num(tx_rx->rx_data, 4); + + // Parity validity check + for(j = 0; j < 4; j++) { + par_array[j] = + (oddparity8(tx_rx->rx_data[j]) != ((tx_rx->rx_parity[0] >> (7 - j)) & 0x01)); + } + + uint32_t ncount = 0; + uint32_t nttest = prng_successor(nt1, dmin - 1); + + for(j = dmin; j < dmax + 1; j++) { + nttest = prng_successor(nttest, 1); + ks1 = nt2 ^ nttest; + + if(valid_nonce(nttest, nt2, ks1, par_array)) { + if(ncount > 0) { // we are only interested in disambiguous nonces, try again + FURI_LOG_D(TAG, "Nonce#%lu: dismissed (ambiguous), ntdist=%lu", i + 1, j); + r.target_nt[i] = 0; + break; + } + + if(delay) { + // will predict later + r.target_nt[i] = nt1; + r.target_ks[i] = nt2; + } else { + r.target_nt[i] = nttest; + r.target_ks[i] = ks1; + } + + memcpy(&r.parity[i], par_array, 4); + ncount++; + + if(i == 1 && + (r.target_nt[0] == r.target_nt[1] || + r.target_ks[0] == r.target_ks[1])) { // we need two different nonces + r.target_nt[i] = 0; + FURI_LOG_D(TAG, "Nonce#2: dismissed (= nonce#1), ntdist=%lu", j); + break; + } + + FURI_LOG_D(TAG, "Nonce#%lu: valid, ntdist=%lu", i + 1, j); + } + } + + if(r.target_nt[i] == 0 && j == dmax + 1) { + FURI_LOG_D(TAG, "Nonce#%lu: dismissed (all invalid)", i + 1); + } + } + } + + if(r.target_nt[0] && r.target_nt[1]) { + r.full = true; + } + + free(crypto); + + nfc_deactivate(); + + return r; +} + +struct nonce_info_hard nested_hard_nonce_attack( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint8_t targetBlockNo, + uint8_t targetKeyType, + uint64_t ui64Key, + uint32_t* found, + uint32_t* first_byte_sum, + Stream* file_stream) { + uint32_t cuid = 0; + uint8_t same = 0; + uint64_t previous = 0; + Crypto1* crypto = malloc(sizeof(Crypto1)); + uint8_t par_array[4] = {0x00}; + struct nonce_info_hard r; + r.full = false; + r.static_encrypted = false; + + for(uint32_t i = 0; i < 8; i++) { + nfc_activate(); + if(!furi_hal_nfc_activate_nfca(200, &cuid)) { + free(crypto); + return r; + } + + r.cuid = cuid; + + if(!mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, NULL)) + continue; + + if(!mifare_sendcmd_short(crypto, tx_rx, true, 0x60 + (targetKeyType & 0x01), targetBlockNo)) + continue; + + uint64_t nt = nfc_util_bytes2num(tx_rx->rx_data, 4); + + for(uint32_t j = 0; j < 4; j++) { + par_array[j] = + (oddparity8(tx_rx->rx_data[j]) != ((tx_rx->rx_parity[0] >> (7 - j)) & 0x01)); + } + + uint8_t pbits = 0; + for(uint8_t j = 0; j < 4; j++) { + uint8_t p = oddparity8(tx_rx->rx_data[j]); + if(par_array[j]) { + p ^= 1; + } + pbits <<= 1; + pbits |= p; + } + + // update unique nonces + if(!found[tx_rx->rx_data[0]]) { + *first_byte_sum += evenparity32(pbits & 0x08); + found[tx_rx->rx_data[0]]++; + } + + if(nt == previous) { + same++; + } + + previous = nt; + + FuriString* row = furi_string_alloc_printf("%llu|%u\n", nt, pbits); + stream_write_string(file_stream, row); + + FURI_LOG_D(TAG, "Accured %lu/8 nonces", i + 1); + furi_string_free(row); + } + + if(same > 4) { + r.static_encrypted = true; + } + + r.full = true; + + free(crypto); + + nfc_deactivate(); + + return r; +} + +NestedCheckKeyResult nested_check_key( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint64_t ui64Key) { + uint32_t cuid = 0; + uint32_t nt; + + nfc_activate(); + if(!furi_hal_nfc_activate_nfca(200, &cuid)) return NestedCheckKeyNoTag; + + FURI_LOG_D( + TAG, "Checking %c key %012llX for block %u", !keyType ? 'A' : 'B', ui64Key, blockNo); + + Crypto1* crypto = malloc(sizeof(Crypto1)); + + bool success = + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, &nt); + + free(crypto); + + nfc_deactivate(); + + return success ? NestedCheckKeyValid : NestedCheckKeyInvalid; +} + +bool nested_check_block(FuriHalNfcTxRxContext* tx_rx, uint8_t blockNo, uint8_t keyType) { + uint32_t cuid = 0; + + nfc_activate(); + if(!furi_hal_nfc_activate_nfca(200, &cuid)) return false; + + Crypto1* crypto = malloc(sizeof(Crypto1)); + + bool success = mifare_sendcmd_short(crypto, tx_rx, false, 0x60 + (keyType & 0x01), blockNo); + + free(crypto); + + nfc_deactivate(); + + return success; +} + +void nested_get_data(FuriHalNfcDevData* dev_data) { + nfc_activate(); + furi_hal_nfc_detect(dev_data, 400); + nfc_deactivate(); +} + +void nfc_activate() { + nfc_deactivate(); + + // Setup nfc poller + furi_hal_nfc_exit_sleep(); + furi_hal_nfc_ll_txrx_on(); + furi_hal_nfc_ll_poll(); + if(furi_hal_nfc_ll_set_mode( + FuriHalNfcModePollNfca, FuriHalNfcBitrate106, FuriHalNfcBitrate106) != + FuriHalNfcReturnOk) + return; + + furi_hal_nfc_ll_set_fdt_listen(FURI_HAL_NFC_LL_FDT_LISTEN_NFCA_POLLER); + furi_hal_nfc_ll_set_fdt_poll(FURI_HAL_NFC_LL_FDT_POLL_NFCA_POLLER); + furi_hal_nfc_ll_set_error_handling(FuriHalNfcErrorHandlingNfc); + furi_hal_nfc_ll_set_guard_time(FURI_HAL_NFC_LL_GT_NFCA); +} + +void nfc_deactivate() { + furi_hal_nfc_ll_txrx_off(); + furi_hal_nfc_start_sleep(); + furi_hal_nfc_sleep(); +} diff --git a/applications/external/mifare_nested/lib/nested/nested.h b/applications/external/mifare_nested/lib/nested/nested.h new file mode 100644 index 0000000000..a2b9024462 --- /dev/null +++ b/applications/external/mifare_nested/lib/nested/nested.h @@ -0,0 +1,118 @@ +#pragma once + +#include +#include +#include + +#include +#include +#include + +typedef enum { + MifareNestedNonceNoTag, + MifareNestedNonceWeak, + MifareNestedNonceStatic, + MifareNestedNonceHard, +} MifareNestedNonceType; + +MifareNestedNonceType nested_check_nonce_type(FuriHalNfcTxRxContext* tx_rx, uint8_t blockNo); + +struct nonce_info_static { + uint32_t cuid; + uint32_t target_nt[2]; + uint32_t target_ks[2]; + bool full; +}; + +struct nonce_info_hard { + uint32_t cuid; + bool static_encrypted; + bool full; +}; + +struct nonce_info { + uint32_t cuid; + uint32_t target_nt[2]; + uint32_t target_ks[2]; + uint8_t parity[2][4]; + bool full; +}; + +struct distance_info { + uint32_t min_prng; + uint32_t max_prng; + uint32_t mid_prng; +}; + +struct nonce_info_static nested_static_nonce_attack( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint8_t targetBlockNo, + uint8_t targetKeyType, + uint64_t ui64Key); + +struct nonce_info nested_attack( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint8_t targetBlockNo, + uint8_t targetKeyType, + uint64_t ui64Key, + uint32_t distance, + uint32_t delay); + +struct nonce_info_hard nested_hard_nonce_attack( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint8_t targetBlockNo, + uint8_t targetKeyType, + uint64_t ui64Key, + uint32_t* found, + uint32_t* first_byte_sum, + Stream* file_stream); + +uint32_t nested_calibrate_distance( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint64_t ui64Key, + uint32_t delay, + bool full); + +struct distance_info nested_calibrate_distance_info( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint64_t ui64Key); + +typedef enum { + NestedCheckKeyNoTag, + NestedCheckKeyValid, + NestedCheckKeyInvalid, +} NestedCheckKeyResult; + +NestedCheckKeyResult nested_check_key( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint64_t ui64Key); + +bool nested_check_block(FuriHalNfcTxRxContext* tx_rx, uint8_t blockNo, uint8_t keyType); + +void nested_get_data(); + +bool mifare_classic_authex( + Crypto1* crypto, + FuriHalNfcTxRxContext* tx_rx, + uint32_t uid, + uint32_t blockNo, + uint32_t keyType, + uint64_t ui64Key, + bool isNested, + uint32_t* ntptr); + +void nfc_activate(); + +void nfc_deactivate(); diff --git a/applications/external/mifare_nested/lib/parity/parity.c b/applications/external/mifare_nested/lib/parity/parity.c new file mode 100644 index 0000000000..c8e2f807e4 --- /dev/null +++ b/applications/external/mifare_nested/lib/parity/parity.c @@ -0,0 +1,71 @@ +#include "parity.h" + +uint32_t __paritysi2(uint32_t a) { + uint32_t x = (uint32_t)a; + x ^= x >> 16; + x ^= x >> 8; + x ^= x >> 4; + return (0x6996 >> (x & 0xF)) & 1; +} + +static const uint8_t g_odd_byte_parity[256] = { + 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, + 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, + 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, + 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, + 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, + 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, + 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, + 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1}; + +#define ODD_PARITY8(x) \ + { g_odd_byte_parity[x] } +#define EVEN_PARITY8(x) \ + { !g_odd_byte_parity[x] } + +uint8_t oddparity8(const uint8_t x) { + return g_odd_byte_parity[x]; +} + +uint8_t evenparity8(const uint8_t x) { + return !g_odd_byte_parity[x]; +} + +uint8_t evenparity16(uint16_t x) { +#if !defined __GNUC__ + x ^= x >> 8; + return EVEN_PARITY8(x); +#else + return (__builtin_parity(x) & 0xFF); +#endif +} + +uint8_t oddparity16(uint16_t x) { +#if !defined __GNUC__ + x ^= x >> 8; + return ODD_PARITY8(x); +#else + return !__builtin_parity(x); +#endif +} + +uint8_t evenparity32(uint32_t x) { +#if !defined __GNUC__ + x ^= x >> 16; + x ^= x >> 8; + return EVEN_PARITY8(x); +#else + return (__builtin_parity(x) & 0xFF); +#endif +} + +uint8_t oddparity32(uint32_t x) { +#if !defined __GNUC__ + x ^= x >> 16; + x ^= x >> 8; + return ODD_PARITY8(x); +#else + return !__builtin_parity(x); +#endif +} \ No newline at end of file diff --git a/applications/external/mifare_nested/lib/parity/parity.h b/applications/external/mifare_nested/lib/parity/parity.h new file mode 100644 index 0000000000..16648afa15 --- /dev/null +++ b/applications/external/mifare_nested/lib/parity/parity.h @@ -0,0 +1,10 @@ +#include "stdint.h" + +uint8_t oddparity8(const uint8_t x); +uint8_t evenparity8(const uint8_t x); + +uint8_t evenparity16(uint16_t x); +uint8_t oddparity16(uint16_t x); + +uint8_t evenparity32(uint32_t x); +uint8_t oddparity32(uint32_t x); \ No newline at end of file diff --git a/applications/external/mifare_nested/mifare_nested.c b/applications/external/mifare_nested/mifare_nested.c new file mode 100644 index 0000000000..237eaef9a6 --- /dev/null +++ b/applications/external/mifare_nested/mifare_nested.c @@ -0,0 +1,408 @@ +#include "mifare_nested_i.h" +#include + +bool mifare_nested_custom_event_callback(void* context, uint32_t event) { + furi_assert(context); + MifareNested* mifare_nested = context; + return scene_manager_handle_custom_event(mifare_nested->scene_manager, event); +} + +bool mifare_nested_back_event_callback(void* context) { + furi_assert(context); + MifareNested* mifare_nested = context; + return scene_manager_handle_back_event(mifare_nested->scene_manager); +} + +void mifare_nested_tick_event_callback(void* context) { + furi_assert(context); + MifareNested* mifare_nested = context; + scene_manager_handle_tick_event(mifare_nested->scene_manager); +} + +void mifare_nested_show_loading_popup(void* context, bool show) { + MifareNested* mifare_nested = context; + TaskHandle_t timer_task = xTaskGetHandle(configTIMER_SERVICE_TASK_NAME); + + if(show) { + // Raise timer priority so that animations can play + vTaskPrioritySet(timer_task, configMAX_PRIORITIES - 1); + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewLoading); + } else { + // Restore default timer priority + vTaskPrioritySet(timer_task, configTIMER_TASK_PRIORITY); + } +} + +NestedState* collection_alloc() { + NestedState* nested = malloc(sizeof(NestedState)); + nested->view = view_alloc(); + view_allocate_model(nested->view, ViewModelTypeLocking, sizeof(NestedAttackViewModel)); + with_view_model( + nested->view, + NestedAttackViewModel * model, + { + model->header = furi_string_alloc(); + furi_string_set(model->header, "Collecting nonces"); + model->keys_count = 0; + model->hardnested_states = 0; + model->lost_tag = false; + model->calibrating = false; + model->need_prediction = false; + model->hardnested = false; + }, + false); + + return nested; +} + +CheckKeysState* check_keys_alloc() { + CheckKeysState* state = malloc(sizeof(CheckKeysState)); + state->view = view_alloc(); + view_allocate_model(state->view, ViewModelTypeLocking, sizeof(CheckKeysViewModel)); + with_view_model( + state->view, + CheckKeysViewModel * model, + { + model->header = furi_string_alloc(); + furi_string_set(model->header, "Checking keys"); + model->lost_tag = false; + }, + false); + + return state; +} + +static void nested_draw_callback(Canvas* canvas, void* model) { + NestedAttackViewModel* m = model; + + if(m->lost_tag) { + canvas_set_font(canvas, FontPrimary); + canvas_draw_str_aligned(canvas, 64, 4, AlignCenter, AlignTop, "Lost the tag!"); + canvas_set_font(canvas, FontSecondary); + elements_multiline_text_aligned( + canvas, 64, 23, AlignCenter, AlignTop, "Make sure the tag is\npositioned correctly."); + } else if(m->calibrating) { + canvas_set_font(canvas, FontPrimary); + canvas_draw_str_aligned(canvas, 64, 4, AlignCenter, AlignTop, "Calibrating..."); + canvas_set_font(canvas, FontSecondary); + if(!m->need_prediction) { + elements_multiline_text_aligned( + canvas, 64, 23, AlignCenter, AlignTop, "Don't touch or move\nFlipper/Tag!"); + } else { + elements_multiline_text_aligned( + canvas, 64, 18, AlignCenter, AlignTop, "Don't touch or move tag!"); + canvas_set_font(canvas, FontPrimary); + elements_multiline_text_aligned( + canvas, 64, 30, AlignCenter, AlignTop, "Calibration will take\nmore time"); + } + } else if(m->hardnested) { + char draw_str[32] = {}; + canvas_set_font(canvas, FontPrimary); + canvas_draw_str_aligned( + canvas, 64, 2, AlignCenter, AlignTop, furi_string_get_cstr(m->header)); + canvas_set_font(canvas, FontSecondary); + + float progress = + m->keys_count == 0 ? 0 : (float)(m->nonces_collected) / (float)(m->keys_count); + + if(progress > 1.0) { + progress = 1.0; + } + + elements_progress_bar(canvas, 5, 15, 120, progress); + canvas_set_font(canvas, FontSecondary); + snprintf( + draw_str, + sizeof(draw_str), + "Nonces collected: %lu/%lu", + m->nonces_collected, + m->keys_count); + canvas_draw_str_aligned(canvas, 1, 28, AlignLeft, AlignTop, draw_str); + snprintf(draw_str, sizeof(draw_str), "States found: %lu/256", m->hardnested_states); + canvas_draw_str_aligned(canvas, 1, 40, AlignLeft, AlignTop, draw_str); + } else { + char draw_str[32] = {}; + canvas_set_font(canvas, FontPrimary); + canvas_draw_str_aligned( + canvas, 64, 2, AlignCenter, AlignTop, furi_string_get_cstr(m->header)); + canvas_set_font(canvas, FontSecondary); + + float progress = + m->keys_count == 0 ? 0 : (float)(m->nonces_collected) / (float)(m->keys_count); + + if(progress > 1.0) { + progress = 1.0; + } + + elements_progress_bar(canvas, 5, 15, 120, progress); + canvas_set_font(canvas, FontSecondary); + snprintf( + draw_str, + sizeof(draw_str), + "Nonces collected: %lu/%lu", + m->nonces_collected, + m->keys_count); + canvas_draw_str_aligned(canvas, 1, 28, AlignLeft, AlignTop, draw_str); + } + + elements_button_center(canvas, "Stop"); +} + +static void check_keys_draw_callback(Canvas* canvas, void* model) { + CheckKeysViewModel* m = model; + + if(m->lost_tag) { + canvas_set_font(canvas, FontPrimary); + canvas_draw_str_aligned(canvas, 64, 4, AlignCenter, AlignTop, "Lost the tag!"); + canvas_set_font(canvas, FontSecondary); + elements_multiline_text_aligned( + canvas, 64, 23, AlignCenter, AlignTop, "Make sure the tag is\npositioned correctly."); + } else if(m->processing_keys) { + canvas_set_font(canvas, FontPrimary); + canvas_draw_str_aligned(canvas, 64, 4, AlignCenter, AlignTop, "Processing keys..."); + canvas_set_font(canvas, FontSecondary); + elements_multiline_text_aligned( + canvas, 64, 23, AlignCenter, AlignTop, "Checking which keys you\nalready have..."); + } else { + char draw_str[32] = {}; + char draw_sub_str[32] = {}; + canvas_set_font(canvas, FontPrimary); + canvas_draw_str_aligned( + canvas, 64, 2, AlignCenter, AlignTop, furi_string_get_cstr(m->header)); + canvas_set_font(canvas, FontSecondary); + + float progress = m->keys_count == 0 ? 0 : + (float)(m->keys_checked) / (float)(m->keys_count); + + if(progress > 1.0) { + progress = 1.0; + } + + elements_progress_bar(canvas, 5, 15, 120, progress); + canvas_set_font(canvas, FontSecondary); + snprintf( + draw_str, sizeof(draw_str), "Keys checked: %lu/%lu", m->keys_checked, m->keys_count); + canvas_draw_str_aligned(canvas, 1, 28, AlignLeft, AlignTop, draw_str); + snprintf( + draw_sub_str, + sizeof(draw_sub_str), + "Keys found: %lu/%lu", + m->keys_found, + m->keys_total); + canvas_draw_str_aligned(canvas, 1, 40, AlignLeft, AlignTop, draw_sub_str); + } + + elements_button_center(canvas, "Stop"); +} + +static bool nested_input_callback(InputEvent* event, void* context) { + MifareNested* mifare_nested = context; + + bool consumed = false; + + if(event->type == InputTypeShort && (event->key == InputKeyBack || event->key == InputKeyOk)) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + + return consumed; +} + +MifareNested* mifare_nested_alloc() { + MifareNested* mifare_nested = malloc(sizeof(MifareNested)); + + mifare_nested->worker = mifare_nested_worker_alloc(); + mifare_nested->view_dispatcher = view_dispatcher_alloc(); + mifare_nested->scene_manager = + scene_manager_alloc(&mifare_nested_scene_handlers, mifare_nested); + view_dispatcher_enable_queue(mifare_nested->view_dispatcher); + view_dispatcher_set_event_callback_context(mifare_nested->view_dispatcher, mifare_nested); + view_dispatcher_set_custom_event_callback( + mifare_nested->view_dispatcher, mifare_nested_custom_event_callback); + view_dispatcher_set_navigation_event_callback( + mifare_nested->view_dispatcher, mifare_nested_back_event_callback); + view_dispatcher_set_tick_event_callback( + mifare_nested->view_dispatcher, mifare_nested_tick_event_callback, 100); + + // Nfc device + mifare_nested->nfc_dev = nfc_device_alloc(); + + // Open GUI record + mifare_nested->gui = furi_record_open(RECORD_GUI); + view_dispatcher_attach_to_gui( + mifare_nested->view_dispatcher, mifare_nested->gui, ViewDispatcherTypeFullscreen); + + // Open Notification record + mifare_nested->notifications = furi_record_open(RECORD_NOTIFICATION); + + // Submenu + mifare_nested->submenu = submenu_alloc(); + view_dispatcher_add_view( + mifare_nested->view_dispatcher, + MifareNestedViewMenu, + submenu_get_view(mifare_nested->submenu)); + + // Popup + mifare_nested->popup = popup_alloc(); + view_dispatcher_add_view( + mifare_nested->view_dispatcher, + MifareNestedViewPopup, + popup_get_view(mifare_nested->popup)); + + // Loading + mifare_nested->loading = loading_alloc(); + view_dispatcher_add_view( + mifare_nested->view_dispatcher, + MifareNestedViewLoading, + loading_get_view(mifare_nested->loading)); + + // Text Input + mifare_nested->text_input = text_input_alloc(); + view_dispatcher_add_view( + mifare_nested->view_dispatcher, + MifareNestedViewTextInput, + text_input_get_view(mifare_nested->text_input)); + + // Custom Widget + mifare_nested->widget = widget_alloc(); + view_dispatcher_add_view( + mifare_nested->view_dispatcher, + MifareNestedViewWidget, + widget_get_view(mifare_nested->widget)); + + // Variable Item List + mifare_nested->variable_item_list = variable_item_list_alloc(); + view_dispatcher_add_view( + mifare_nested->view_dispatcher, + MifareNestedViewVariableList, + variable_item_list_get_view(mifare_nested->variable_item_list)); + + // Nested attack state + NestedState* plugin_state = collection_alloc(); + view_set_context(plugin_state->view, mifare_nested); + mifare_nested->nested_state = plugin_state; + view_dispatcher_add_view( + mifare_nested->view_dispatcher, MifareNestedViewCollecting, plugin_state->view); + + // Check keys attack state + CheckKeysState* keys_state = check_keys_alloc(); + view_set_context(keys_state->view, mifare_nested); + mifare_nested->keys_state = keys_state; + view_dispatcher_add_view( + mifare_nested->view_dispatcher, MifareNestedViewCheckKeys, keys_state->view); + + KeyInfo_t* key_info = malloc(sizeof(KeyInfo_t)); + mifare_nested->keys = key_info; + + MifareNestedSettings* settings = malloc(sizeof(MifareNestedSettings)); + settings->only_hardnested = false; + mifare_nested->settings = settings; + + view_set_draw_callback(plugin_state->view, nested_draw_callback); + view_set_input_callback(plugin_state->view, nested_input_callback); + + view_set_draw_callback(keys_state->view, check_keys_draw_callback); + view_set_input_callback(keys_state->view, nested_input_callback); + + mifare_nested->collecting_type = MifareNestedWorkerStateReady; + mifare_nested->run = NestedRunIdle; + + return mifare_nested; +} + +void mifare_nested_free(MifareNested* mifare_nested) { + furi_assert(mifare_nested); + + // Nfc device + nfc_device_free(mifare_nested->nfc_dev); + + // Submenu + view_dispatcher_remove_view(mifare_nested->view_dispatcher, MifareNestedViewMenu); + submenu_free(mifare_nested->submenu); + + // Popup + view_dispatcher_remove_view(mifare_nested->view_dispatcher, MifareNestedViewPopup); + popup_free(mifare_nested->popup); + + // Loading + view_dispatcher_remove_view(mifare_nested->view_dispatcher, MifareNestedViewLoading); + loading_free(mifare_nested->loading); + + // TextInput + view_dispatcher_remove_view(mifare_nested->view_dispatcher, MifareNestedViewTextInput); + text_input_free(mifare_nested->text_input); + + // Custom Widget + view_dispatcher_remove_view(mifare_nested->view_dispatcher, MifareNestedViewWidget); + widget_free(mifare_nested->widget); + + // Variable Item List + view_dispatcher_remove_view(mifare_nested->view_dispatcher, MifareNestedViewVariableList); + variable_item_list_free(mifare_nested->variable_item_list); + + // Nested + view_dispatcher_remove_view(mifare_nested->view_dispatcher, MifareNestedViewCollecting); + + // Check keys + view_dispatcher_remove_view(mifare_nested->view_dispatcher, MifareNestedViewCheckKeys); + + // Nonces states + free(mifare_nested->nonces); + free(mifare_nested->nested_state); + + // Keys + free(mifare_nested->keys); + + // Settings + free(mifare_nested->settings); + + // Worker + mifare_nested_worker_stop(mifare_nested->worker); + mifare_nested_worker_free(mifare_nested->worker); + + // View Dispatcher + view_dispatcher_free(mifare_nested->view_dispatcher); + + // Scene Manager + scene_manager_free(mifare_nested->scene_manager); + + // GUI + furi_record_close(RECORD_GUI); + mifare_nested->gui = NULL; + + // Notifications + furi_record_close(RECORD_NOTIFICATION); + mifare_nested->notifications = NULL; + + free(mifare_nested); +} + +void mifare_nested_blink_start(MifareNested* mifare_nested) { + notification_message(mifare_nested->notifications, &mifare_nested_sequence_blink_start_blue); +} + +void mifare_nested_blink_calibration_start(MifareNested* mifare_nested) { + notification_message( + mifare_nested->notifications, &mifare_nested_sequence_blink_start_magenta); +} + +void mifare_nested_blink_nonce_collection_start(MifareNested* mifare_nested) { + notification_message(mifare_nested->notifications, &mifare_nested_sequence_blink_start_yellow); +} + +void mifare_nested_blink_stop(MifareNested* mifare_nested) { + notification_message(mifare_nested->notifications, &mifare_nested_sequence_blink_stop); +} + +int32_t mifare_nested_app(void* p) { + UNUSED(p); + MifareNested* mifare_nested = mifare_nested_alloc(); + + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneStart); + + view_dispatcher_run(mifare_nested->view_dispatcher); + + mifare_nested_free(mifare_nested); + + return 0; +} diff --git a/applications/external/mifare_nested/mifare_nested.h b/applications/external/mifare_nested/mifare_nested.h new file mode 100644 index 0000000000..a59a5b8cac --- /dev/null +++ b/applications/external/mifare_nested/mifare_nested.h @@ -0,0 +1,3 @@ +#pragma once + +typedef struct MifareNested MifareNested; diff --git a/applications/external/mifare_nested/mifare_nested_i.h b/applications/external/mifare_nested/mifare_nested_i.h new file mode 100644 index 0000000000..59aab5825d --- /dev/null +++ b/applications/external/mifare_nested/mifare_nested_i.h @@ -0,0 +1,180 @@ +#pragma once +#include "mifare_nested.h" +#include "mifare_nested_worker.h" +#include "lib/nested/nested.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "scenes/mifare_nested_scene.h" +#include +#include +#include +#include +#include +#include "mifare_nested_icons.h" + +#define NESTED_VERSION_APP "1.4.6" +#define NESTED_GITHUB_LINK "https://github.com/AloneLiberty/FlipperNested" +#define NESTED_RECOVER_KEYS_GITHUB_LINK "https://github.com/AloneLiberty/FlipperNestedRecovery" +#define NESTED_NONCE_FORMAT_VERSION "3" +#define NESTED_AUTHOR "@AloneLiberty (t.me/libertydev)" + +enum MifareNestedCustomEvent { + // Reserve first 100 events for button types and indexes, starting from 0 + MifareNestedCustomEventReserved = 100, + + MifareNestedCustomEventViewExit, + MifareNestedCustomEventWorkerExit, + MifareNestedCustomEventByteInputDone, + MifareNestedCustomEventTextInputDone, + MifareNestedCustomEventSceneSettingLock +}; + +typedef void (*NestedCallback)(void* context); + +typedef struct { + FuriMutex* mutex; + FuriMessageQueue* event_queue; + ViewPort* view_port; + View* view; + NestedCallback callback; + void* context; +} NestedState; + +typedef void (*CheckKeysCallback)(void* context); + +typedef struct { + FuriMutex* mutex; + FuriMessageQueue* event_queue; + ViewPort* view_port; + View* view; + CheckKeysCallback callback; + void* context; +} CheckKeysState; + +typedef enum { + EventTypeTick, + EventTypeKey, +} EventType; + +typedef struct { + EventType type; + InputEvent input; +} PluginEvent; + +typedef struct { + bool only_hardnested; +} MifareNestedSettings; + +typedef enum { NestedRunIdle, NestedRunCheckKeys, NestedRunAttack } NestedRunNext; + +struct MifareNested { + MifareNestedWorker* worker; + ViewDispatcher* view_dispatcher; + Gui* gui; + NotificationApp* notifications; + SceneManager* scene_manager; + NfcDevice* nfc_dev; + VariableItemList* variable_item_list; + MifareNestedSettings* settings; + FuriString* text_box_store; + + // Common Views + Submenu* submenu; + Popup* popup; + Loading* loading; + TextInput* text_input; + Widget* widget; + + NonceList_t* nonces; + KeyInfo_t* keys; + + NestedState* nested_state; + CheckKeysState* keys_state; + + MifareNestedWorkerState collecting_type; + + NestedRunNext run; +}; + +typedef enum { + MifareNestedViewMenu, + MifareNestedViewPopup, + MifareNestedViewLoading, + MifareNestedViewTextInput, + MifareNestedViewWidget, + MifareNestedViewVariableList, + MifareNestedViewCollecting, + MifareNestedViewCheckKeys, +} MifareNestedView; + +typedef struct { + FuriString* header; + uint32_t keys_count; + uint32_t nonces_collected; + uint32_t hardnested_states; + bool lost_tag; + bool calibrating; + bool need_prediction; + bool hardnested; +} NestedAttackViewModel; + +typedef struct { + FuriString* header; + uint32_t keys_count; + uint32_t keys_checked; + uint32_t keys_found; + uint32_t keys_total; + bool lost_tag; + bool processing_keys; +} CheckKeysViewModel; + +static const NotificationSequence mifare_nested_sequence_blink_start_blue = { + &message_blink_start_10, + &message_blink_set_color_blue, + &message_do_not_reset, + NULL, +}; + +static const NotificationSequence mifare_nested_sequence_blink_start_magenta = { + &message_blink_start_10, + &message_blink_set_color_magenta, + &message_do_not_reset, + NULL, +}; + +static const NotificationSequence mifare_nested_sequence_blink_start_yellow = { + &message_blink_start_10, + &message_blink_set_color_yellow, + &message_do_not_reset, + NULL, +}; + +static const NotificationSequence mifare_nested_sequence_blink_stop = { + &message_blink_stop, + NULL, +}; + +MifareNested* mifare_nested_alloc(); + +void mifare_nested_text_store_set(MifareNested* mifare_nested, const char* text, ...); + +void mifare_nested_text_store_clear(MifareNested* mifare_nested); + +void mifare_nested_blink_start(MifareNested* mifare_nested); + +void mifare_nested_blink_calibration_start(MifareNested* mifare_nested); + +void mifare_nested_blink_nonce_collection_start(MifareNested* mifare_nested); + +void mifare_nested_blink_stop(MifareNested* mifare_nested); + +void mifare_nested_show_loading_popup(void* context, bool show); diff --git a/applications/external/mifare_nested/mifare_nested_worker.c b/applications/external/mifare_nested/mifare_nested_worker.c new file mode 100644 index 0000000000..56d2f24271 --- /dev/null +++ b/applications/external/mifare_nested/mifare_nested_worker.c @@ -0,0 +1,1663 @@ +#include "mifare_nested_worker_i.h" + +#include "lib/nested/nested.h" +#include "lib/parity/parity.h" +#include + +#include +#include +#include +#include "string.h" +#include +#include + +#define TAG "MifareNestedWorker" + +// possible sum property values +static uint16_t sums[] = + {0, 32, 56, 64, 80, 96, 104, 112, 120, 128, 136, 144, 152, 160, 176, 192, 200, 224, 256}; + +void mifare_nested_worker_change_state( + MifareNestedWorker* mifare_nested_worker, + MifareNestedWorkerState state) { + furi_assert(mifare_nested_worker); + + mifare_nested_worker->state = state; +} + +MifareNestedWorker* mifare_nested_worker_alloc() { + MifareNestedWorker* mifare_nested_worker = malloc(sizeof(MifareNestedWorker)); + + // Worker thread attributes + mifare_nested_worker->thread = furi_thread_alloc_ex( + "MifareNestedWorker", 8192, mifare_nested_worker_task, mifare_nested_worker); + + mifare_nested_worker->callback = NULL; + mifare_nested_worker->context = NULL; + + mifare_nested_worker_change_state(mifare_nested_worker, MifareNestedWorkerStateReady); + + return mifare_nested_worker; +} + +void mifare_nested_worker_free(MifareNestedWorker* mifare_nested_worker) { + furi_assert(mifare_nested_worker); + + furi_thread_free(mifare_nested_worker->thread); + free(mifare_nested_worker); +} + +void mifare_nested_worker_stop(MifareNestedWorker* mifare_nested_worker) { + furi_assert(mifare_nested_worker); + + mifare_nested_worker_change_state(mifare_nested_worker, MifareNestedWorkerStateStop); + furi_thread_join(mifare_nested_worker->thread); +} + +void mifare_nested_worker_start( + MifareNestedWorker* mifare_nested_worker, + MifareNestedWorkerState state, + NfcDeviceData* dev_data, + MifareNestedWorkerCallback callback, + void* context) { + furi_assert(mifare_nested_worker); + furi_assert(dev_data); + + mifare_nested_worker->callback = callback; + mifare_nested_worker->context = context; + mifare_nested_worker->dev_data = dev_data; + mifare_nested_worker_change_state(mifare_nested_worker, state); + furi_thread_start(mifare_nested_worker->thread); +} + +int32_t mifare_nested_worker_task(void* context) { + MifareNestedWorker* mifare_nested_worker = context; + + if(mifare_nested_worker->state == MifareNestedWorkerStateCheck) { + mifare_nested_worker_check(mifare_nested_worker); + } else if(mifare_nested_worker->state == MifareNestedWorkerStateCollectingStatic) { + mifare_nested_worker_collect_nonces_static(mifare_nested_worker); + } else if(mifare_nested_worker->state == MifareNestedWorkerStateCollecting) { + mifare_nested_worker_collect_nonces(mifare_nested_worker); + } else if(mifare_nested_worker->state == MifareNestedWorkerStateCollectingHard) { + mifare_nested_worker_collect_nonces_hard(mifare_nested_worker); + } else if(mifare_nested_worker->state == MifareNestedWorkerStateValidating) { + mifare_nested_worker_check_keys(mifare_nested_worker); + } + + mifare_nested_worker_change_state(mifare_nested_worker, MifareNestedWorkerStateReady); + + return 0; +} + +void mifare_nested_worker_write_uid_string(FuriHalNfcDevData* data, FuriString* string) { + uint8_t* uid = data->uid; + uint8_t uid_len = data->uid_len; + + for(size_t i = 0; i < uid_len; i++) { + uint8_t uid_part = uid[i]; + furi_string_cat_printf(string, "%02X", uid_part); + } +} + +void mifare_nested_worker_get_key_cache_file_path(FuriHalNfcDevData* data, FuriString* file_path) { + furi_string_set(file_path, EXT_PATH("nfc/.cache") "/"); + + mifare_nested_worker_write_uid_string(data, file_path); + + furi_string_cat_printf(file_path, ".keys"); +} + +void mifare_nested_worker_get_nonces_file_path(FuriHalNfcDevData* data, FuriString* file_path) { + furi_string_set(file_path, NESTED_FOLDER "/"); + + mifare_nested_worker_write_uid_string(data, file_path); + + furi_string_cat_printf(file_path, ".nonces"); +} + +void mifare_nested_worker_get_found_keys_file_path(FuriHalNfcDevData* data, FuriString* file_path) { + furi_string_set(file_path, NESTED_FOLDER "/"); + + mifare_nested_worker_write_uid_string(data, file_path); + + furi_string_cat_printf(file_path, ".keys"); +} + +void mifare_nested_worker_get_hardnested_folder_path( + FuriHalNfcDevData* data, + FuriString* file_path) { + furi_string_set(file_path, NESTED_FOLDER "/"); + + mifare_nested_worker_write_uid_string(data, file_path); +} + +void mifare_nested_worker_get_hardnested_file_path( + FuriHalNfcDevData* data, + FuriString* file_path, + uint8_t sector, + uint8_t key_type) { + mifare_nested_worker_get_hardnested_folder_path(data, file_path); + + furi_string_cat_printf(file_path, "/%u_%u.nonces", sector, key_type); +} + +uint8_t mifare_nested_worker_get_block_by_sector(uint8_t sector) { + furi_assert(sector < 40); + if(sector < 32) { + return (sector * 4) + 3; + } else { + return 32 * 4 + (sector - 32) * 16 + 15; + } +} + +static MfClassicSectorTrailer* + mifare_nested_worker_get_sector_trailer_by_sector(MfClassicData* data, uint8_t sector) { + return (MfClassicSectorTrailer*)data->block[mifare_nested_worker_get_block_by_sector(sector)] + .value; +} + +bool mifare_nested_worker_read_key_cache(FuriHalNfcDevData* data, MfClassicData* mf_data) { + Storage* storage = furi_record_open(RECORD_STORAGE); + FuriString* temp_str = furi_string_alloc(); + mifare_nested_worker_get_key_cache_file_path(data, temp_str); + FlipperFormat* file = flipper_format_file_alloc(storage); + bool load_success = false; + uint32_t sector_count = 0; + + do { + if(storage_common_stat(storage, furi_string_get_cstr(temp_str), NULL) != FSE_OK) break; + + if(!flipper_format_file_open_existing(file, furi_string_get_cstr(temp_str))) break; + + uint32_t version = 0; + + if(!flipper_format_read_header(file, temp_str, &version)) break; + if(furi_string_cmp_str(temp_str, "Flipper NFC keys")) break; + + if(version != 1) break; + + if(!flipper_format_read_string(file, "Mifare Classic type", temp_str)) break; + + if(!furi_string_cmp(temp_str, "1K")) { + mf_data->type = MfClassicType1k; + sector_count = 16; + } else if(!furi_string_cmp(temp_str, "4K")) { + mf_data->type = MfClassicType4k; + sector_count = 40; + } else if(!furi_string_cmp(temp_str, "MINI")) { + mf_data->type = MfClassicTypeMini; + sector_count = 5; + } else { + break; + } + + if(!flipper_format_read_hex_uint64(file, "Key A map", &mf_data->key_a_mask, 1)) break; + if(!flipper_format_read_hex_uint64(file, "Key B map", &mf_data->key_b_mask, 1)) break; + + bool key_read_success = true; + + for(size_t i = 0; (i < sector_count) && (key_read_success); i++) { + MfClassicSectorTrailer* sec_tr = + mifare_nested_worker_get_sector_trailer_by_sector(mf_data, i); + + if(FURI_BIT(mf_data->key_a_mask, i)) { + furi_string_printf(temp_str, "Key A sector %d", i); + key_read_success = flipper_format_read_hex( + file, furi_string_get_cstr(temp_str), sec_tr->key_a, 6); + } + + if(!key_read_success) break; + + if(FURI_BIT(mf_data->key_b_mask, i)) { + furi_string_printf(temp_str, "Key B sector %d", i); + key_read_success = flipper_format_read_hex( + file, furi_string_get_cstr(temp_str), sec_tr->key_b, 6); + } + } + + load_success = key_read_success; + } while(false); + + furi_string_free(temp_str); + flipper_format_free(file); + + return load_success; +} + +bool hex_char_to_hex_nibble(char c, uint8_t* nibble) { + if((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')) { + if(c <= '9') { + *nibble = c - '0'; + } else if(c <= 'F') { + *nibble = c - 'A' + 10; + } else { + *nibble = c - 'a' + 10; + } + return true; + } else { + return false; + } +} + +bool hex_char_to_uint8(char hi, char low, uint8_t* value) { + uint8_t hi_nibble_value, low_nibble_value; + + if(hex_char_to_hex_nibble(hi, &hi_nibble_value) && + hex_char_to_hex_nibble(low, &low_nibble_value)) { + *value = (hi_nibble_value << 4) | low_nibble_value; + return true; + } else { + return false; + } +} + +void free_nonces(NonceList_t* nonces, uint8_t sector_count, uint8_t tries_count) { + for(uint8_t sector = 0; sector < sector_count; sector++) { + for(uint8_t key_type = 0; key_type < 2; key_type++) { + for(uint8_t tries = 0; tries < tries_count; tries++) { + free(nonces->nonces[sector][key_type][tries]); + } + } + } +} + +MfClassicType mifare_nested_worker_get_tag_type(uint8_t ATQA0, uint8_t ATQA1, uint8_t SAK) { + UNUSED(ATQA1); + if((ATQA0 == 0x44 || ATQA0 == 0x04)) { + if((SAK == 0x08 || SAK == 0x88)) { + return MfClassicType1k; + } else if(SAK == 0x09) { + return MfClassicTypeMini; + } + } else if((ATQA0 == 0x01) && (ATQA1 == 0x0F) && (SAK == 0x01)) { + //skylanders support + return MfClassicType1k; + } else if((ATQA0 == 0x42 || ATQA0 == 0x02) && (SAK == 0x18)) { + return MfClassicType4k; + } + return MfClassicType1k; +} + +uint32_t mifare_nested_worker_predict_delay( + FuriHalNfcTxRxContext* tx_rx, + uint8_t blockNo, + uint8_t keyType, + uint64_t ui64Key, + uint32_t tries, + MifareNestedWorker* mifare_nested_worker) { + uint32_t cuid = 0; + Crypto1* crypto = malloc(sizeof(Crypto1)); + uint32_t nt1, nt2, i = 0, previous = 0, prng_delay = 0, zero_prng_value = 65565, repeat = 0; + + if(tries > 25) { + free(crypto); + return 2; // Too many tries, fallback to hardnested + } + + // This part of attack is my attempt to implement it on Flipper. + // Proxmark can do this in 2 fucking steps, but idk how. + + // First, we find RPNG rounds per 1000 us + for(uint32_t rtr = 0; rtr < 25; rtr++) { + if(mifare_nested_worker->state != MifareNestedWorkerStateCollecting) { + free(crypto); + return 1; + } + + nfc_activate(); + if(!furi_hal_nfc_activate_nfca(200, &cuid)) break; + + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, &nt1); + + furi_delay_us(rtr * 1000); + + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, true, &nt2); + + // Searching for delay, where PRNG will be near 800 + uint32_t nttmp = prng_successor(nt1, 100); + + for(i = 101; i < 65565; i++) { + nttmp = prng_successor(nttmp, 1); + if(nttmp == nt2) break; + } + + if(!rtr) { + zero_prng_value = i; + } + + if(previous && i > previous && i != 65565) { + if(!prng_delay) { + prng_delay = i - previous; + } else if(prng_delay - 100 > i - previous && prng_delay + 100 < i - previous) { + prng_delay += i - previous; + prng_delay /= 2; + } + } + + previous = i; + + FURI_LOG_D(TAG, "Calibrating: ntdist=%lu, delay=%lu", i, rtr * 1000); + + // Let's hope... + if(i > 810 && i < 840) { + free(crypto); + return rtr * 1000; + } + } + + FURI_LOG_D(TAG, "PRNG timing: growth ratio per 1000 us = %lu", prng_delay); + + // Next, we try to calculate time until PRNG near 800 with more perfect timing + // Mifare Classic (weak) RPNG repeats every 65565 PRNG cycles + + if(zero_prng_value == 65565) { + free(crypto); + // PRNG isn't pretictable + return 1; + } + + uint32_t cycles_to_reset = (65565 - zero_prng_value) / prng_delay; + + uint32_t limit = 7; + + for(uint32_t rtr = cycles_to_reset - 1; rtr < cycles_to_reset + limit; rtr++) { + for(uint32_t rtz = 0; rtz < 100; rtz++) { + if(mifare_nested_worker->state != MifareNestedWorkerStateCollecting) { + free(crypto); + return 1; + } + + nfc_activate(); + if(!furi_hal_nfc_activate_nfca(200, &cuid)) break; + + uint32_t delay = rtr * 1000 + rtz * 10; + + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, &nt1); + + furi_delay_us(delay); + + mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, true, &nt2); + + // Searching for delay, where PRNG will be near 800 + uint32_t nttmp = prng_successor(nt1, 0); + + for(i = 1; i < 65565; i++) { + nttmp = prng_successor(nttmp, 1); + if(nttmp == nt2) break; + } + + if(!(i > previous - 50 && i < previous + 50) && rtz) { + repeat++; + + if(repeat < 5) { + FURI_LOG_D(TAG, "Invalid RPNG value: ntdist=%lu", i); + + continue; + } + } + + if(i > 2000 && i < 65500) { + uint32_t catch_cycles = (65565 - i) / prng_delay; + if(catch_cycles > 2) { + catch_cycles++; + + FURI_LOG_D( + TAG, + "Trying a more accurate value: skipping additional %lu us", + catch_cycles * 1000); + limit += catch_cycles + 2; + rtr += catch_cycles; + } + } + + FURI_LOG_D( + TAG, + "Calibrating: ntdist=%lu, delay=%lu, max=%lu", + i, + delay, + (cycles_to_reset + limit) * 1000); + + repeat = 0; + previous = i; + + if(i > 810 && i < 840) { + free(crypto); + FURI_LOG_I(TAG, "Found delay: %lu us", delay); + return delay; + } else if(i > 840 && i < 40000) { + FURI_LOG_D(TAG, "Trying again: timing lost"); + tries++; + free(crypto); + return mifare_nested_worker_predict_delay( + tx_rx, blockNo, keyType, ui64Key, tries, mifare_nested_worker); + } + } + } + + if(i > 1000 && i < 65000) { + FURI_LOG_D(TAG, "Trying again: wrong predicted timing"); + tries++; + free(crypto); + return mifare_nested_worker_predict_delay( + tx_rx, blockNo, keyType, ui64Key, tries, mifare_nested_worker); + } + + free(crypto); + + return 1; +} + +void mifare_nested_worker_write_nonces( + FuriHalNfcDevData* data, + Storage* storage, + NonceList_t* nonces, + uint8_t tries_count, + uint8_t free_tries_count, + uint8_t sector_count, + uint32_t delay, + uint32_t distance) { + FuriString* path = furi_string_alloc(); + Stream* file_stream = file_stream_alloc(storage); + mifare_nested_worker_get_nonces_file_path(data, path); + + file_stream_open(file_stream, furi_string_get_cstr(path), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS); + + FuriString* header = furi_string_alloc_printf( + "Filetype: Flipper Nested Nonce Manifest File\nVersion: %s\nNote: you will need desktop app to recover keys: %s\n", + NESTED_NONCE_FORMAT_VERSION, + NESTED_RECOVER_KEYS_GITHUB_LINK); + stream_write_string(file_stream, header); + + for(uint8_t tries = 0; tries < tries_count; tries++) { + for(uint8_t sector = 0; sector < sector_count; sector++) { + for(uint8_t key_type = 0; key_type < 2; key_type++) { + if(nonces->nonces[sector][key_type][tries]->collected && + !nonces->nonces[sector][key_type][tries]->skipped) { + if(nonces->nonces[sector][key_type][tries]->hardnested) { + FuriString* path = furi_string_alloc(); + mifare_nested_worker_get_hardnested_file_path( + data, path, sector, key_type); + + FuriString* str = furi_string_alloc_printf( + "HardNested: Key %c cuid 0x%08lx file %s sec %u\n", + !key_type ? 'A' : 'B', + nonces->cuid, + furi_string_get_cstr(path), + sector); + + stream_write_string(file_stream, str); + + furi_string_free(path); + furi_string_free(str); + } else { + FuriString* str = furi_string_alloc_printf( + "Nested: Key %c cuid 0x%08lx", !key_type ? 'A' : 'B', nonces->cuid); + + for(uint8_t type = 0; type < 2; type++) { + furi_string_cat_printf( + str, + " nt%u 0x%08lx ks%u 0x%08lx par%u ", + type, + nonces->nonces[sector][key_type][tries]->target_nt[type], + type, + nonces->nonces[sector][key_type][tries]->target_ks[type], + type); + + uint8_t* par = nonces->nonces[sector][key_type][tries]->parity[type]; + for(uint8_t i = 0; i < 4; i++) { + furi_string_cat_printf(str, "%u", par[i]); + } + } + + furi_string_cat_printf(str, " sec %u\n", sector); + + stream_write_string(file_stream, str); + furi_string_free(str); + } + } + } + } + } + + if(delay) { + FuriString* str = + furi_string_alloc_printf("Nested: Delay %lu, distance %lu", delay, distance); + + stream_write_string(file_stream, str); + furi_string_free(str); + } + + free_nonces(nonces, sector_count, free_tries_count); + furi_string_free(path); + file_stream_close(file_stream); + free(file_stream); + furi_record_close(RECORD_STORAGE); +} + +bool mifare_nested_worker_check_initial_keys( + NonceList_t* nonces, + MfClassicData* mf_data, + uint8_t tries_count, + uint8_t sector_count, + uint64_t* key, + uint32_t* key_block, + uint32_t* found_key_type) { + bool has_a_key, has_b_key; + FuriHalNfcTxRxContext tx_rx = {}; + + for(uint8_t sector = 0; sector < sector_count; sector++) { + for(uint8_t key_type = 0; key_type < 2; key_type++) { + for(uint8_t tries = 0; tries < tries_count; tries++) { + Nonces* info = malloc(sizeof(Nonces)); + info->key_type = key_type; + info->block = mifare_nested_worker_get_block_by_sector(sector); + info->collected = false; + info->skipped = true; + + nonces->nonces[sector][key_type][tries] = info; + } + } + } + + for(uint8_t sector = 0; sector < sector_count; sector++) { + MfClassicSectorTrailer* trailer = + mifare_nested_worker_get_sector_trailer_by_sector(mf_data, sector); + has_a_key = FURI_BIT(mf_data->key_a_mask, sector); + has_b_key = FURI_BIT(mf_data->key_b_mask, sector); + + if(has_a_key) { + for(uint8_t tries = 0; tries < tries_count; tries++) { + Nonces* info = nonces->nonces[sector][0][tries]; + info->collected = true; + info->skipped = true; + + nonces->nonces[sector][0][tries] = info; + } + + if(*key_block == 0) { + uint64_t key_check = nfc_util_bytes2num(trailer->key_a, 6); + if(nested_check_key( + &tx_rx, mifare_nested_worker_get_block_by_sector(sector), 0, key_check) == + NestedCheckKeyValid) { + *key = key_check; + *key_block = mifare_nested_worker_get_block_by_sector(sector); + *found_key_type = 0; + } + } + } + + if(has_b_key) { + for(uint8_t tries = 0; tries < tries_count; tries++) { + Nonces* info = nonces->nonces[sector][1][tries]; + info->collected = true; + info->skipped = true; + + nonces->nonces[sector][1][tries] = info; + } + + if(*key_block == 0) { + uint64_t key_check = nfc_util_bytes2num(trailer->key_b, 6); + if(nested_check_key( + &tx_rx, mifare_nested_worker_get_block_by_sector(sector), 1, key_check) == + NestedCheckKeyValid) { + *key = key_check; + *key_block = mifare_nested_worker_get_block_by_sector(sector); + *found_key_type = 1; + } + } + } + } + + nonces->cuid = 0; + nonces->hardnested_states = 0; + nonces->sector_count = sector_count; + nonces->tries = tries_count; + + return *key_block; +} + +void mifare_nested_worker_check(MifareNestedWorker* mifare_nested_worker) { + while(mifare_nested_worker->state == MifareNestedWorkerStateCheck) { + FuriHalNfcTxRxContext tx_rx = {}; + NfcDevice* dev = mifare_nested_worker->context->nfc_dev; + MfClassicData* mf_data = &dev->dev_data.mf_classic_data; + FuriHalNfcDevData data = {}; + MifareNestedNonceType type = MifareNestedNonceNoTag; + nested_get_data(&data); + + if(mifare_nested_worker_read_key_cache(&data, mf_data)) { + for(uint8_t sector = 0; sector < 40; sector++) { + if(FURI_BIT(mf_data->key_a_mask, sector) || + FURI_BIT(mf_data->key_b_mask, sector)) { + type = nested_check_nonce_type( + &tx_rx, mifare_nested_worker_get_block_by_sector(sector)); + break; + } + } + + if(type == MifareNestedNonceNoTag) { + type = nested_check_nonce_type(&tx_rx, 0); + } + } else { + type = nested_check_nonce_type(&tx_rx, 0); + } + + if(type == MifareNestedNonceStatic) { + mifare_nested_worker->context->collecting_type = + MifareNestedWorkerStateCollectingStatic; + + mifare_nested_worker->callback( + MifareNestedWorkerEventCollecting, mifare_nested_worker->context); + + break; + } else if(type == MifareNestedNonceWeak) { + mifare_nested_worker->context->collecting_type = MifareNestedWorkerStateCollecting; + + mifare_nested_worker->callback( + MifareNestedWorkerEventCollecting, mifare_nested_worker->context); + + break; + } else if(type == MifareNestedNonceHard) { + mifare_nested_worker->context->collecting_type = MifareNestedWorkerStateCollectingHard; + + mifare_nested_worker->callback( + MifareNestedWorkerEventCollecting, mifare_nested_worker->context); + + break; + } + + furi_delay_ms(250); + } + + nfc_deactivate(); +} + +void mifare_nested_worker_collect_nonces_static(MifareNestedWorker* mifare_nested_worker) { + NonceList_t nonces; + Storage* storage = furi_record_open(RECORD_STORAGE); + NfcDevice* dev = mifare_nested_worker->context->nfc_dev; + MfClassicData* mf_data = &dev->dev_data.mf_classic_data; + FuriString* folder_path = furi_string_alloc(); + FuriHalNfcDevData data = {}; + nested_get_data(&data); + MfClassicType type = mifare_nested_worker_get_tag_type(data.atqa[0], data.atqa[1], data.sak); + uint64_t key = 0; // Found key for attack + uint32_t found_key_type = 0; + uint32_t key_block = 0; + uint32_t sector_count = 0; + + FURI_LOG_I(TAG, "Running Static Nested attack"); + FuriString* tag_info = furi_string_alloc_printf("Tag UID: "); + mifare_nested_worker_write_uid_string(&data, tag_info); + FURI_LOG_I(TAG, "%s", furi_string_get_cstr(tag_info)); + furi_string_free(tag_info); + + if(type == MfClassicType4k) { + sector_count = 40; + FURI_LOG_I(TAG, "Found Mifare Classic 4K tag"); + } else if(type == MfClassicType1k) { + sector_count = 16; + FURI_LOG_I(TAG, "Found Mifare Classic 1K tag"); + } else { // if(type == MfClassicTypeMini) + sector_count = 5; + FURI_LOG_I(TAG, "Found Mifare Classic Mini tag"); + } + + furi_string_set(folder_path, NESTED_FOLDER); + storage_common_mkdir(storage, furi_string_get_cstr(folder_path)); + furi_string_free(folder_path); + + if(!mifare_nested_worker_read_key_cache(&data, mf_data) || + !mifare_nested_worker_check_initial_keys( + &nonces, mf_data, 1, sector_count, &key, &key_block, &found_key_type)) { + mifare_nested_worker->callback( + MifareNestedWorkerEventNeedKey, mifare_nested_worker->context); + nfc_deactivate(); + + free(mf_data); + free_nonces(&nonces, sector_count, 1); + + return; + } + + FURI_LOG_I( + TAG, "Using %c key for block %lu: %012llX", !found_key_type ? 'A' : 'B', key_block, key); + + while(mifare_nested_worker->state == MifareNestedWorkerStateCollectingStatic) { + FuriHalNfcTxRxContext tx_rx = {}; + + for(uint8_t sector = 0; sector < sector_count; sector++) { + for(uint8_t key_type = 0; key_type < 2; key_type++) { + Nonces* info = nonces.nonces[sector][key_type][0]; + + if(info->collected) { + FURI_LOG_I( + TAG, + "Skipping sector %u, block %u, key_type: %u as we already have a key", + sector, + mifare_nested_worker_get_block_by_sector(sector), + key_type); + + info->skipped = true; + + nonces.nonces[sector][key_type][0] = info; + + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback( + MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + continue; + } + + if(!nested_check_block( + &tx_rx, mifare_nested_worker_get_block_by_sector(sector), key_type)) { + FURI_LOG_E( + TAG, + "Skipping sector %u, block %u, key_type: %u as we can't auth on it", + sector, + mifare_nested_worker_get_block_by_sector(sector), + key_type); + + info->skipped = true; + + nonces.nonces[sector][key_type][0] = info; + + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback( + MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + + continue; + } + + while(!info->collected) { + if(mifare_nested_worker->state != MifareNestedWorkerStateCollectingStatic) { + break; + } + + struct nonce_info_static result = nested_static_nonce_attack( + &tx_rx, + key_block, + found_key_type, + mifare_nested_worker_get_block_by_sector(sector), + key_type, + key); + if(result.full) { + FURI_LOG_I( + TAG, + "Accured nonces for sector %u, block %u, key_type: %u", + sector, + mifare_nested_worker_get_block_by_sector(sector), + key_type); + + info = nonces.nonces[sector][key_type][0]; + info->collected = true; + info->skipped = false; + + memcpy(&info->target_nt, result.target_nt, sizeof(result.target_nt)); + memcpy(&info->target_ks, result.target_ks, sizeof(result.target_ks)); + + nonces.nonces[sector][key_type][0] = info; + nonces.cuid = result.cuid; + nonces.sector_count = sector_count; + + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback( + MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + break; + } else { + mifare_nested_worker->callback( + MifareNestedWorkerEventNoTagDetected, mifare_nested_worker->context); + } + } + } + } + + break; + } + + mifare_nested_worker_write_nonces(&data, storage, &nonces, 1, 1, sector_count, 0, 0); + + free(mf_data); + + mifare_nested_worker->callback( + MifareNestedWorkerEventNoncesCollected, mifare_nested_worker->context); + + nfc_deactivate(); +} + +void mifare_nested_worker_collect_nonces_hard(MifareNestedWorker* mifare_nested_worker) { + NonceList_t nonces; + Storage* storage = furi_record_open(RECORD_STORAGE); + NfcDevice* dev = mifare_nested_worker->context->nfc_dev; + MfClassicData* mf_data = &dev->dev_data.mf_classic_data; + FuriString* folder_path = furi_string_alloc(); + FuriHalNfcDevData data = {}; + nested_get_data(&data); + MfClassicType type = mifare_nested_worker_get_tag_type(data.atqa[0], data.atqa[1], data.sak); + uint64_t key = 0; // Found key for attack + uint32_t found_key_type = 0; + uint32_t key_block = 0; + uint32_t sector_count = 0; + uint32_t cuid = 0; + furi_hal_nfc_activate_nfca(200, &cuid); + + FURI_LOG_I(TAG, "Running Hard Nested attack"); + FuriString* tag_info = furi_string_alloc_printf("Tag UID: "); + mifare_nested_worker_write_uid_string(&data, tag_info); + FURI_LOG_I(TAG, "%s", furi_string_get_cstr(tag_info)); + furi_string_free(tag_info); + + if(type == MfClassicType4k) { + sector_count = 40; + FURI_LOG_I(TAG, "Found Mifare Classic 4K tag"); + } else if(type == MfClassicType1k) { + sector_count = 16; + FURI_LOG_I(TAG, "Found Mifare Classic 1K tag"); + } else { // if(type == MfClassicTypeMini) + sector_count = 5; + FURI_LOG_I(TAG, "Found Mifare Classic Mini tag"); + } + + furi_string_set(folder_path, NESTED_FOLDER); + storage_common_mkdir(storage, furi_string_get_cstr(folder_path)); + mifare_nested_worker_get_hardnested_folder_path(&data, folder_path); + storage_common_mkdir(storage, furi_string_get_cstr(folder_path)); + furi_string_free(folder_path); + + if(!mifare_nested_worker_read_key_cache(&data, mf_data) || + !mifare_nested_worker_check_initial_keys( + &nonces, mf_data, 1, sector_count, &key, &key_block, &found_key_type)) { + mifare_nested_worker->callback( + MifareNestedWorkerEventNeedKey, mifare_nested_worker->context); + nfc_deactivate(); + + free(mf_data); + free_nonces(&nonces, sector_count, 1); + + return; + } + + FURI_LOG_I( + TAG, "Using %c key for block %lu: %012llX", !found_key_type ? 'A' : 'B', key_block, key); + + FuriHalNfcTxRxContext tx_rx = {}; + nonces.tries = 1; + nonces.hardnested_states = 0; + nonces.sector_count = sector_count; + + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback(MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + + mifare_nested_worker->callback( + MifareNestedWorkerEventHardnestedStatesFound, mifare_nested_worker->context); + + for(uint8_t sector = 0; sector < sector_count && + mifare_nested_worker->state == MifareNestedWorkerStateCollectingHard; + sector++) { + for(uint8_t key_type = 0; + key_type < 2 && mifare_nested_worker->state == MifareNestedWorkerStateCollectingHard; + key_type++) { + Nonces* info = nonces.nonces[sector][key_type][0]; + if(info->collected) { + FURI_LOG_I( + TAG, + "Skipping sector %u, block %u, key_type: %u as we already have a key", + sector, + mifare_nested_worker_get_block_by_sector(sector), + key_type); + + info->skipped = true; + + nonces.nonces[sector][key_type][0] = info; + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback( + MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + + continue; + } + + if(!nested_check_block( + &tx_rx, mifare_nested_worker_get_block_by_sector(sector), key_type)) { + FURI_LOG_E( + TAG, + "Skipping sector %u, block %u, key_type: %u as we can't auth on it", + sector, + mifare_nested_worker_get_block_by_sector(sector), + key_type); + + info->skipped = true; + + nonces.nonces[sector][key_type][0] = info; + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback( + MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + + continue; + } + + while(!info->collected && + mifare_nested_worker->state == MifareNestedWorkerStateCollectingHard) { + Stream* file_stream = file_stream_alloc(storage); + FuriString* hardnested_file = furi_string_alloc(); + mifare_nested_worker_get_hardnested_file_path( + &data, hardnested_file, sector, key_type); + + file_stream_open( + file_stream, + furi_string_get_cstr(hardnested_file), + FSAM_READ_WRITE, + FSOM_CREATE_ALWAYS); + + FuriString* header = furi_string_alloc_printf( + "Filetype: Flipper Nested Nonces File\nVersion: %s\nNote: you will need desktop app to recover keys: %s\nKey %c cuid 0x%08lx sec %u\n", + NESTED_NONCE_FORMAT_VERSION, + NESTED_RECOVER_KEYS_GITHUB_LINK, + !key_type ? 'A' : 'B', + cuid, + sector); + + stream_write_string(file_stream, header); + furi_string_free(header); + + uint32_t first_byte_sum = 0; + uint32_t* found = malloc(sizeof(uint32_t) * 256); + for(uint32_t i = 0; i < 256; i++) { + found[i] = 0; + } + + while(mifare_nested_worker->state == MifareNestedWorkerStateCollectingHard) { + struct nonce_info_hard result = nested_hard_nonce_attack( + &tx_rx, + key_block, + found_key_type, + mifare_nested_worker_get_block_by_sector(sector), + key_type, + key, + found, + &first_byte_sum, + file_stream); + + if(result.static_encrypted) { + file_stream_close(file_stream); + + storage_simply_remove(storage, furi_string_get_cstr(hardnested_file)); + + furi_string_free(hardnested_file); + free(found); + free(mf_data); + nfc_deactivate(); + + mifare_nested_worker->callback( + MifareNestedWorkerEventStaticEncryptedNonce, + mifare_nested_worker->context); + + return; + } + + if(result.full) { + uint32_t states = 0; + for(uint32_t i = 0; i < 256; i++) { + states += found[i]; + } + + nonces.hardnested_states = states; + + mifare_nested_worker->callback( + MifareNestedWorkerEventHardnestedStatesFound, + mifare_nested_worker->context); + + FURI_LOG_D(TAG, "Found states: %lu", states); + + if(states == 256) { + FURI_LOG_D( + TAG, "All states collected, first_byte_sum: %lu", first_byte_sum); + + bool valid = false; + for(uint8_t i = 0; i < sizeof(sums); i++) { + if(sums[i] == first_byte_sum) { + valid = true; + break; + } + } + + if(!valid) { + FURI_LOG_E(TAG, "Invalid first_byte_sum!"); + break; + } + + info->collected = true; + info->hardnested = true; + info->skipped = false; + + nonces.cuid = result.cuid; + + nonces.nonces[sector][key_type][0] = info; + + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback( + MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + + break; + } + } else { + mifare_nested_worker->callback( + MifareNestedWorkerEventNoTagDetected, mifare_nested_worker->context); + } + } + + free(found); + furi_string_free(hardnested_file); + file_stream_close(file_stream); + } + } + } + + mifare_nested_worker_write_nonces(&data, storage, &nonces, 1, 1, sector_count, 0, 0); + + free(mf_data); + + mifare_nested_worker->callback( + MifareNestedWorkerEventNoncesCollected, mifare_nested_worker->context); + + nfc_deactivate(); +} + +void mifare_nested_worker_collect_nonces(MifareNestedWorker* mifare_nested_worker) { + NonceList_t nonces; + Storage* storage = furi_record_open(RECORD_STORAGE); + NfcDevice* dev = mifare_nested_worker->context->nfc_dev; + MfClassicData* mf_data = &dev->dev_data.mf_classic_data; + FuriString* folder_path = furi_string_alloc(); + FuriHalNfcDevData data = {}; + nested_get_data(&data); + MfClassicType type = mifare_nested_worker_get_tag_type(data.atqa[0], data.atqa[1], data.sak); + uint64_t key = 0; // Found key for attack + uint32_t found_key_type = 0; + uint32_t key_block = 0; + uint32_t sector_count = 0; + uint32_t delay = 0; + uint32_t distance = 0; + uint32_t tries_count = 1; + + FURI_LOG_I(TAG, "Running Nested attack"); + FuriString* tag_info = furi_string_alloc_printf("Tag UID: "); + mifare_nested_worker_write_uid_string(&data, tag_info); + FURI_LOG_I(TAG, "%s", furi_string_get_cstr(tag_info)); + furi_string_free(tag_info); + + if(type == MfClassicType4k) { + sector_count = 40; + FURI_LOG_I(TAG, "Found Mifare Classic 4K tag"); + } else if(type == MfClassicType1k) { + sector_count = 16; + FURI_LOG_I(TAG, "Found Mifare Classic 1K tag"); + } else { // if(type == MfClassicTypeMini) + sector_count = 5; + FURI_LOG_I(TAG, "Found Mifare Classic Mini tag"); + } + + furi_string_set(folder_path, NESTED_FOLDER); + storage_common_mkdir(storage, furi_string_get_cstr(folder_path)); + furi_string_free(folder_path); + + if(!mifare_nested_worker_read_key_cache(&data, mf_data) || + !mifare_nested_worker_check_initial_keys( + &nonces, mf_data, 3, sector_count, &key, &key_block, &found_key_type)) { + mifare_nested_worker->callback( + MifareNestedWorkerEventNeedKey, mifare_nested_worker->context); + nfc_deactivate(); + + free(mf_data); + free_nonces(&nonces, sector_count, 3); + + return; + } + + FURI_LOG_I( + TAG, "Using %c key for block %lu: %012llX", !found_key_type ? 'A' : 'B', key_block, key); + + while(mifare_nested_worker->state == MifareNestedWorkerStateCollecting) { + FuriHalNfcTxRxContext tx_rx = {}; + uint32_t first_distance = 0; + uint32_t second_distance = 0; + + mifare_nested_worker->callback( + MifareNestedWorkerEventCalibrating, mifare_nested_worker->context); + + distance = nested_calibrate_distance(&tx_rx, key_block, found_key_type, key, delay, false); + + if(mifare_nested_worker->state == MifareNestedWorkerStateCollecting) { + first_distance = + nested_calibrate_distance(&tx_rx, key_block, found_key_type, key, delay, true); + } + + if(mifare_nested_worker->state == MifareNestedWorkerStateCollecting) { + second_distance = + nested_calibrate_distance(&tx_rx, key_block, found_key_type, key, 10000, true); + } + + if(first_distance == 0 && second_distance == 0) { + nfc_deactivate(); + + free(mf_data); + free_nonces(&nonces, sector_count, 3); + + mifare_nested_worker_change_state( + mifare_nested_worker, MifareNestedWorkerStateCollectingHard); + + mifare_nested_worker_collect_nonces_hard(mifare_nested_worker); + return; + } + + if(first_distance < second_distance - 100 && second_distance > 100) { + FURI_LOG_E( + TAG, + "Discovered tag with PRNG that depends on time. PRNG values: %lu, %lu", + first_distance, + second_distance); + + struct distance_info info = + nested_calibrate_distance_info(&tx_rx, key_block, found_key_type, key); + + if(info.max_prng - info.min_prng > 150) { + FURI_LOG_W( + TAG, + "PRNG is too unpredictable (min/max values more than 150: %lu - %lu = %lu), fallback to delay method", + info.max_prng, + info.min_prng, + info.max_prng - info.min_prng); + + delay = 1; + } else { + FURI_LOG_I( + TAG, + "PRNG is stable, using method without delay! (May be false positive, still will collect x3 times)"); + + distance = + nested_calibrate_distance(&tx_rx, key_block, found_key_type, key, delay, true); + + delay = 2; + tries_count = 3; + } + } + + if(distance == 0 || delay == 1) { + bool failed = false; + // Tag need delay or unpredictable PRNG + FURI_LOG_W(TAG, "Can't determine distance, trying to find timing..."); + + mifare_nested_worker->callback( + MifareNestedWorkerEventNeedPrediction, mifare_nested_worker->context); + + delay = mifare_nested_worker_predict_delay( + &tx_rx, key_block, found_key_type, key, 0, mifare_nested_worker); + + if(delay == 1) { + FURI_LOG_E(TAG, "Can't determine delay"); + + // Check that we didn't lost tag + FuriHalNfcDevData lost_tag_data = {}; + nested_get_data(&lost_tag_data); + if(lost_tag_data.uid_len == 0) { + // We lost it. + mifare_nested_worker->callback( + MifareNestedWorkerEventNoTagDetected, mifare_nested_worker->context); + + while(mifare_nested_worker->state == MifareNestedWorkerStateCollecting && + lost_tag_data.cuid != data.cuid) { + furi_delay_ms(250); + nested_get_data(&lost_tag_data); + } + + mifare_nested_worker->callback( + MifareNestedWorkerEventCalibrating, mifare_nested_worker->context); + + continue; + } + + failed = true; + } + + if(delay == 2) { + FURI_LOG_E(TAG, "Can't determine delay in 25 tries, fallback to hardnested"); + + nfc_deactivate(); + + free(mf_data); + free_nonces(&nonces, sector_count, 3); + + mifare_nested_worker_change_state( + mifare_nested_worker, MifareNestedWorkerStateCollectingHard); + + mifare_nested_worker_collect_nonces_hard(mifare_nested_worker); + return; + } + + if(mifare_nested_worker->state == MifareNestedWorkerStateCollecting && !failed) { + distance = nested_calibrate_distance( + &tx_rx, key_block, found_key_type, key, delay, false); + } + + if(distance == 0 && !failed) { + FURI_LOG_E(TAG, "Found delay, but can't find distance"); + + failed = true; + } + + if(failed) { + nfc_deactivate(); + + mifare_nested_worker->callback( + MifareNestedWorkerEventAttackFailed, mifare_nested_worker->context); + + free(mf_data); + free_nonces(&nonces, sector_count, 3); + + return; + } + + tries_count = 3; + } + + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback( + MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + + for(uint8_t tries = 0; tries < tries_count; tries++) { + for(uint8_t sector = 0; sector < sector_count; sector++) { + for(uint8_t key_type = 0; key_type < 2; key_type++) { + Nonces* info = nonces.nonces[sector][key_type][tries]; + if(info->collected) { + FURI_LOG_I( + TAG, + "Skipping sector %u, block %u, key_type: %u as we already have a key", + sector, + mifare_nested_worker_get_block_by_sector(sector), + key_type); + + info->skipped = true; + + nonces.nonces[sector][key_type][tries] = info; + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback( + MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + + continue; + } + + if(!nested_check_block( + &tx_rx, mifare_nested_worker_get_block_by_sector(sector), key_type)) { + FURI_LOG_E( + TAG, + "Skipping sector %u, block %u, key_type: %u as we can't auth on it", + sector, + mifare_nested_worker_get_block_by_sector(sector), + key_type); + + info->skipped = true; + + nonces.nonces[sector][key_type][0] = info; + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback( + MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + + continue; + } + + while(!info->collected) { + if(mifare_nested_worker->state != MifareNestedWorkerStateCollecting) { + break; + } + + struct nonce_info result = nested_attack( + &tx_rx, + key_block, + found_key_type, + mifare_nested_worker_get_block_by_sector(sector), + key_type, + key, + distance, + delay); + + if(result.full) { + FURI_LOG_I( + TAG, + "Accured nonces for sector %u, block %u, key_type: %u", + sector, + mifare_nested_worker_get_block_by_sector(sector), + key_type); + + info = nonces.nonces[sector][key_type][tries]; + info->collected = true; + info->skipped = false; + + memcpy(&info->target_nt, result.target_nt, sizeof(result.target_nt)); + memcpy(&info->target_ks, result.target_ks, sizeof(result.target_ks)); + memcpy(&info->parity, result.parity, sizeof(result.parity)); + + nonces.nonces[sector][key_type][tries] = info; + nonces.cuid = result.cuid; + nonces.sector_count = sector_count; + nonces.tries = tries_count; + + mifare_nested_worker->context->nonces = &nonces; + + mifare_nested_worker->callback( + MifareNestedWorkerEventNewNonce, mifare_nested_worker->context); + break; + } else { + mifare_nested_worker->callback( + MifareNestedWorkerEventNoTagDetected, + mifare_nested_worker->context); + } + } + } + } + } + + break; + } + + mifare_nested_worker_write_nonces( + &data, storage, &nonces, tries_count, 3, sector_count, delay, distance); + + free(mf_data); + + mifare_nested_worker->callback( + MifareNestedWorkerEventNoncesCollected, mifare_nested_worker->context); + + nfc_deactivate(); +} + +bool* mifare_nested_worker_check_keys_exists( + Storage* storage, + char* path, + uint64_t* keys, + uint32_t key_count, + MifareNestedWorker* mifare_nested_worker) { + bool* old_keys = malloc(sizeof(bool) * key_count); + Stream* file_stream = file_stream_alloc(storage); + file_stream_open(file_stream, path, FSAM_READ, FSOM_OPEN_ALWAYS); + FuriString* key_strings[key_count]; + + for(uint32_t i = 0; i < key_count; i++) { + old_keys[i] = false; + key_strings[i] = furi_string_alloc_printf("%012llX\n", keys[i]); + } + + while(mifare_nested_worker->state == MifareNestedWorkerStateValidating) { + FuriString* next_line = furi_string_alloc(); + + if(!stream_read_line(file_stream, next_line)) { + break; + } + + for(uint32_t i = 0; i < key_count; i++) { + if(keys[i] == (uint64_t)-1) continue; + + if(furi_string_cmp(next_line, key_strings[i]) == 0) { + old_keys[i] = true; + } + } + + furi_string_free(next_line); + } + + for(uint32_t i = 0; i < key_count; i++) { + furi_string_free(key_strings[i]); + } + + file_stream_close(file_stream); + free(file_stream); + + return old_keys; +} + +void mifare_nested_worker_write_key(Storage* storage, FuriString* key) { + Stream* file_stream = file_stream_alloc(storage); + file_stream_open( + file_stream, + EXT_PATH("nfc/assets/mf_classic_dict_user.nfc"), + FSAM_READ_WRITE, + FSOM_OPEN_APPEND); + + stream_write_string(file_stream, key); + + file_stream_close(file_stream); +} + +void mifare_nested_worker_check_keys(MifareNestedWorker* mifare_nested_worker) { + KeyInfo_t* key_info = mifare_nested_worker->context->keys; + Storage* storage = furi_record_open(RECORD_STORAGE); + Stream* file_stream = file_stream_alloc(storage); + FuriString* next_line = furi_string_alloc(); + FuriString* path = furi_string_alloc(); + FuriHalNfcDevData data = {}; + nested_get_data(&data); + MfClassicType type = mifare_nested_worker_get_tag_type(data.atqa[0], data.atqa[1], data.sak); + NestedCheckKeyResult result = NestedCheckKeyNoTag; + FuriHalNfcTxRxContext tx_rx = {}; + uint32_t key_count = 0; + uint32_t sector_key_count = 0; + uint64_t keys[80]; + bool found_keys[2][40]; + bool unique_keys[2][40]; + uint32_t sector_count = 0; + + if(type == MfClassicType4k) { + sector_count = 40; + FURI_LOG_I(TAG, "Found Mifare Classic 4K tag"); + } else if(type == MfClassicType1k) { + sector_count = 16; + FURI_LOG_I(TAG, "Found Mifare Classic 1K tag"); + } else { // if(type == MfClassicTypeMini) + sector_count = 5; + FURI_LOG_I(TAG, "Found Mifare Classic Mini tag"); + } + + uint32_t keys_count = sector_count * 2; + + for(uint8_t key = 0; key < 2; key++) { + for(uint8_t i = 0; i < sector_count; i++) { + found_keys[key][i] = false; + unique_keys[key][i] = false; + } + } + + for(uint8_t i = 0; i < keys_count; i++) { + keys[i] = -1; + } + + mifare_nested_worker_get_found_keys_file_path(&data, path); + + if(!file_stream_open(file_stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) { + FURI_LOG_E(TAG, "Can't open %s", furi_string_get_cstr(path)); + + file_stream_close(file_stream); + + mifare_nested_worker_get_nonces_file_path(&data, path); + + if(!file_stream_open( + file_stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) { + mifare_nested_worker->callback( + MifareNestedWorkerEventNeedCollection, mifare_nested_worker->context); + } else { + mifare_nested_worker->callback( + MifareNestedWorkerEventNeedKeyRecovery, mifare_nested_worker->context); + } + + file_stream_close(file_stream); + + free(file_stream); + furi_string_free(path); + furi_string_free(next_line); + furi_record_close(RECORD_STORAGE); + + return; + }; + + while(true) { + if(!stream_read_line(file_stream, next_line)) { + break; + } + + if(furi_string_start_with_str(next_line, "Key")) { + uint8_t key_type = furi_string_get_char(next_line, 4) == 'B'; + uint8_t sector = atoi((char[]){furi_string_get_char(next_line, 13)}) * 10 + + atoi((char[]){furi_string_get_char(next_line, 14)}); + + if(!unique_keys[key_type][sector]) { + unique_keys[key_type][sector] = true; + sector_key_count++; + } + } + + key_count++; + } + + stream_rewind(file_stream); + + key_info->total_keys = key_count; + key_info->sector_keys = sector_key_count; + + while(mifare_nested_worker->state == MifareNestedWorkerStateValidating) { + if(!stream_read_line(file_stream, next_line)) { + break; + } + + if(furi_string_start_with_str(next_line, "Key")) { + // Key X sector XX: XX XX XX XX XX XX + // 0000000000111111111122222222223333 + // 0123456789012345678901234567890123 + uint8_t keyChar[6]; + uint8_t count = 0; + + uint8_t key_type = furi_string_get_char(next_line, 4) == 'B'; + uint8_t sector = atoi((char[]){furi_string_get_char(next_line, 13)}) * 10 + + atoi((char[]){furi_string_get_char(next_line, 14)}); + + for(uint8_t i = 17; i < 33; i += 3) { + hex_char_to_uint8( + furi_string_get_char(next_line, i), + furi_string_get_char(next_line, i + 1), + &keyChar[count]); + count++; + } + + uint64_t key = nfc_util_bytes2num(keyChar, 6); + + key_info->checked_keys++; + + if(found_keys[key_type][sector]) { + mifare_nested_worker->callback( + MifareNestedWorkerEventKeyChecked, mifare_nested_worker->context); + + continue; + } + + while(mifare_nested_worker->state == MifareNestedWorkerStateValidating) { + result = nested_check_key( + &tx_rx, mifare_nested_worker_get_block_by_sector(sector), key_type, key); + + if(result == NestedCheckKeyNoTag) { + mifare_nested_worker->callback( + MifareNestedWorkerEventNoTagDetected, mifare_nested_worker->context); + + furi_delay_ms(250); + } else { + break; + } + } + + if(result == NestedCheckKeyValid) { + FURI_LOG_I( + TAG, "Found valid %c key for sector %u: %012llX", key_type, sector, key); + bool exists = false; + + for(uint8_t i = 0; i < keys_count; i++) { + if(keys[i] == key) { + exists = true; + } + } + + if(!exists) { + keys[key_info->found_keys] = key; + } + + key_info->found_keys++; + found_keys[key_type][sector] = true; + } + + mifare_nested_worker->callback( + MifareNestedWorkerEventKeyChecked, mifare_nested_worker->context); + } + } + + furi_string_free(next_line); + file_stream_close(file_stream); + free(file_stream); + + mifare_nested_worker->callback( + MifareNestedWorkerEventProcessingKeys, mifare_nested_worker->context); + + bool* old_keys = mifare_nested_worker_check_keys_exists( + storage, + EXT_PATH("nfc/assets/mf_classic_dict_user.nfc"), + keys, + keys_count, + mifare_nested_worker); + + for(uint8_t i = 0; i < keys_count; i++) { + if(old_keys[i]) { + keys[i] = -1; + } + } + + old_keys = mifare_nested_worker_check_keys_exists( + storage, + EXT_PATH("nfc/assets/mf_classic_dict.nfc"), + keys, + keys_count, + mifare_nested_worker); + + for(uint8_t i = 0; i < keys_count; i++) { + if(old_keys[i]) { + keys[i] = -1; + } + } + + for(uint8_t i = 0; i < keys_count; i++) { + if(keys[i] == (uint64_t)-1) continue; + + FuriString* key_string = furi_string_alloc_printf("%012llX\n", keys[i]); + + mifare_nested_worker_write_key(storage, key_string); + FURI_LOG_I(TAG, "Added new key: %s", furi_string_get_cstr(key_string)); + + key_info->added_keys++; + + furi_string_free(key_string); + } + + if(!storage_simply_remove(storage, furi_string_get_cstr(path))) { + FURI_LOG_E(TAG, "Failed to remove .keys file"); + } + + furi_record_close(RECORD_STORAGE); + furi_string_free(path); + + mifare_nested_worker->callback( + MifareNestedWorkerEventKeysFound, mifare_nested_worker->context); + + return; +} \ No newline at end of file diff --git a/applications/external/mifare_nested/mifare_nested_worker.h b/applications/external/mifare_nested/mifare_nested_worker.h new file mode 100644 index 0000000000..5616206768 --- /dev/null +++ b/applications/external/mifare_nested/mifare_nested_worker.h @@ -0,0 +1,89 @@ +#pragma once + +#include + +#define NESTED_FOLDER EXT_PATH("nfc/.nested") + +typedef struct MifareNestedWorker MifareNestedWorker; + +typedef enum { + MifareNestedWorkerStateReady, + + MifareNestedWorkerStateCheck, + MifareNestedWorkerStateCollecting, + MifareNestedWorkerStateCollectingStatic, + MifareNestedWorkerStateCollectingHard, + MifareNestedWorkerStateValidating, + + MifareNestedWorkerStateStop, +} MifareNestedWorkerState; + +typedef enum { + MifareNestedWorkerEventReserved = 1000, + + MifareNestedWorkerEventNoTagDetected, + MifareNestedWorkerEventNoncesCollected, + MifareNestedWorkerEventCollecting, + + MifareNestedWorkerEventNewNonce, + MifareNestedWorkerEventKeyChecked, + MifareNestedWorkerEventKeysFound, + MifareNestedWorkerEventNeedKey, + MifareNestedWorkerEventAttackFailed, + MifareNestedWorkerEventCalibrating, + MifareNestedWorkerEventStaticEncryptedNonce, + MifareNestedWorkerEventNeedPrediction, + MifareNestedWorkerEventProcessingKeys, + MifareNestedWorkerEventNeedKeyRecovery, + MifareNestedWorkerEventNeedCollection, + MifareNestedWorkerEventHardnestedStatesFound +} MifareNestedWorkerEvent; + +typedef bool (*MifareNestedWorkerCallback)(MifareNestedWorkerEvent event, void* context); + +MifareNestedWorker* mifare_nested_worker_alloc(); + +void mifare_nested_worker_change_state( + MifareNestedWorker* mifare_nested_worker, + MifareNestedWorkerState state); + +void mifare_nested_worker_free(MifareNestedWorker* mifare_nested_worker); + +void mifare_nested_worker_stop(MifareNestedWorker* mifare_nested_worker); + +void mifare_nested_worker_start( + MifareNestedWorker* mifare_nested_worker, + MifareNestedWorkerState state, + NfcDeviceData* dev_data, + MifareNestedWorkerCallback callback, + void* context); + +typedef struct { + uint32_t key_type; + uint32_t block; + uint32_t target_nt[2]; + uint32_t target_ks[2]; + uint8_t parity[2][4]; + bool collected; + bool skipped; + bool hardnested; +} Nonces; + +typedef struct { + uint32_t cuid; + uint32_t sector_count; + // 40 (or 16/5) sectors, 2 keys (A/B), 3 tries + Nonces* nonces[40][2][3]; + uint32_t tries; + // unique first bytes + uint32_t hardnested_states; +} NonceList_t; + +typedef struct { + uint32_t total_keys; + uint32_t checked_keys; + uint32_t found_keys; + uint32_t added_keys; + uint32_t sector_keys; + bool tag_lost; +} KeyInfo_t; diff --git a/applications/external/mifare_nested/mifare_nested_worker_i.h b/applications/external/mifare_nested/mifare_nested_worker_i.h new file mode 100644 index 0000000000..fd82535d00 --- /dev/null +++ b/applications/external/mifare_nested/mifare_nested_worker_i.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include "mifare_nested_i.h" +#include "mifare_nested_worker.h" + +struct MifareNestedWorker { + FuriThread* thread; + + NfcDeviceData* dev_data; + + MifareNestedWorkerCallback callback; + MifareNested* context; + + MifareNestedWorkerState state; +}; + +int32_t mifare_nested_worker_task(void* context); + +void mifare_nested_worker_check(MifareNestedWorker* mifare_nested_worker); + +void mifare_nested_worker_collect_nonces(MifareNestedWorker* mifare_nested_worker); + +void mifare_nested_worker_collect_nonces_static(MifareNestedWorker* mifare_nested_worker); + +void mifare_nested_worker_collect_nonces_hard(MifareNestedWorker* mifare_nested_worker); + +void mifare_nested_worker_check_keys(MifareNestedWorker* mifare_nested_worker); diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene.c b/applications/external/mifare_nested/scenes/mifare_nested_scene.c new file mode 100644 index 0000000000..3962ed908c --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene.c @@ -0,0 +1,30 @@ +#include "mifare_nested_scene.h" + +// Generate scene on_enter handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, +void (*const mifare_nested_on_enter_handlers[])(void*) = { +#include "mifare_nested_scene_config.h" +}; +#undef ADD_SCENE + +// Generate scene on_event handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, +bool (*const mifare_nested_on_event_handlers[])(void* context, SceneManagerEvent event) = { +#include "mifare_nested_scene_config.h" +}; +#undef ADD_SCENE + +// Generate scene on_exit handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, +void (*const mifare_nested_on_exit_handlers[])(void* context) = { +#include "mifare_nested_scene_config.h" +}; +#undef ADD_SCENE + +// Initialize scene handlers configuration structure +const SceneManagerHandlers mifare_nested_scene_handlers = { + .on_enter_handlers = mifare_nested_on_enter_handlers, + .on_event_handlers = mifare_nested_on_event_handlers, + .on_exit_handlers = mifare_nested_on_exit_handlers, + .scene_num = MifareNestedSceneNum, +}; diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene.h b/applications/external/mifare_nested/scenes/mifare_nested_scene.h new file mode 100644 index 0000000000..e9596f2220 --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene.h @@ -0,0 +1,29 @@ +#pragma once + +#include + +// Generate scene id and total number +#define ADD_SCENE(prefix, name, id) MifareNestedScene##id, +typedef enum { +#include "mifare_nested_scene_config.h" + MifareNestedSceneNum, +} MifareNestedScene; +#undef ADD_SCENE + +extern const SceneManagerHandlers mifare_nested_scene_handlers; + +// Generate scene on_enter handlers declaration +#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); +#include "mifare_nested_scene_config.h" +#undef ADD_SCENE + +// Generate scene on_event handlers declaration +#define ADD_SCENE(prefix, name, id) \ + bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); +#include "mifare_nested_scene_config.h" +#undef ADD_SCENE + +// Generate scene on_exit handlers declaration +#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); +#include "mifare_nested_scene_config.h" +#undef ADD_SCENE diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_about.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_about.c new file mode 100644 index 0000000000..cb07f81a3b --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_about.c @@ -0,0 +1,77 @@ +#include "../mifare_nested_i.h" + +void mifare_nested_scene_about_widget_callback(GuiButtonType result, InputType type, void* context) { + MifareNested* mifare_nested = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result); + } +} + +void mifare_nested_scene_about_on_enter(void* context) { + MifareNested* mifare_nested = context; + + FuriString* temp_str; + temp_str = furi_string_alloc(); + furi_string_printf(temp_str, "\e#%s\n", "Information"); + + furi_string_cat_printf(temp_str, "Version: %s\n", NESTED_VERSION_APP); + furi_string_cat_printf(temp_str, "Developed by:\n%s\n\n", NESTED_AUTHOR); + furi_string_cat_printf(temp_str, "Github: %s\n\n", NESTED_GITHUB_LINK); + + furi_string_cat_printf(temp_str, "\e#%s\n", "Description"); + furi_string_cat_printf( + temp_str, + "Ported Nested attacks\nfrom Proxmark3 (Iceman fork)\nCurrently supported attacks:\n - nested attack\n - static nested attack\n - hard nested attack\n\n"); + furi_string_cat_printf( + temp_str, + "You will need desktop app to recover keys from collected nonces: %s\n\n", + NESTED_RECOVER_KEYS_GITHUB_LINK); + furi_string_cat_printf(temp_str, "\e#%s\n", "Quick guide"); + furi_string_cat_printf(temp_str, "1. Install key recovery script on PC:\n"); + furi_string_cat_printf(temp_str, "pip install FlipperNested\n"); + furi_string_cat_printf(temp_str, "2. Connect Flipper Zero to PC\n"); + furi_string_cat_printf(temp_str, "3. Run key recovery:\n"); + furi_string_cat_printf(temp_str, "FlipperNested"); + + widget_add_text_box_element( + mifare_nested->widget, + 0, + 0, + 128, + 14, + AlignCenter, + AlignBottom, + "\e#\e! \e!\n", + false); + widget_add_text_box_element( + mifare_nested->widget, + 0, + 2, + 128, + 14, + AlignCenter, + AlignBottom, + "\e#\e! Flipper (Mifare) Nested \e!\n", + false); + widget_add_text_scroll_element( + mifare_nested->widget, 0, 16, 128, 50, furi_string_get_cstr(temp_str)); + furi_string_free(temp_str); + + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget); +} + +bool mifare_nested_scene_about_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + UNUSED(mifare_nested); + UNUSED(event); + + return consumed; +} + +void mifare_nested_scene_about_on_exit(void* context) { + MifareNested* mifare_nested = context; + + // Clear views + widget_reset(mifare_nested->widget); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_added_keys.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_added_keys.c new file mode 100644 index 0000000000..f5627a3008 --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_added_keys.c @@ -0,0 +1,76 @@ +#include "../mifare_nested_i.h" + +void mifare_nested_scene_added_keys_widget_callback( + GuiButtonType result, + InputType type, + void* context) { + MifareNested* mifare_nested = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result); + } +} + +void mifare_nested_scene_added_keys_on_enter(void* context) { + MifareNested* mifare_nested = context; + KeyInfo_t* key_info = mifare_nested->keys; + Widget* widget = mifare_nested->widget; + char draw_str[32] = {}; + char append[5] = {'k', 'e', 'y', ' ', '\0'}; + if(key_info->added_keys != 1) { + append[3] = 's'; + } + + widget_add_string_element( + widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "Results of key recovery"); + + if(key_info->added_keys != 0) { + snprintf(draw_str, sizeof(draw_str), "Added: %lu %s", key_info->added_keys, append); + notification_message(mifare_nested->notifications, &sequence_success); + widget_add_icon_element(widget, 52, 17, &I_DolphinSuccess); + } else { + snprintf(draw_str, sizeof(draw_str), "No new keys were added"); + widget_add_string_element( + widget, 0, 22, AlignLeft, AlignTop, FontSecondary, "Try running \"Nested attack\""); + widget_add_string_element(widget, 0, 32, AlignLeft, AlignTop, FontSecondary, "again"); + notification_message(mifare_nested->notifications, &sequence_error); + } + + widget_add_string_element(widget, 0, 12, AlignLeft, AlignTop, FontSecondary, draw_str); + widget_add_button_element( + widget, + GuiButtonTypeLeft, + "Back", + mifare_nested_scene_added_keys_widget_callback, + mifare_nested); + + free(key_info); + + KeyInfo_t* new_key_info = malloc(sizeof(KeyInfo_t)); + mifare_nested->keys = new_key_info; + + // Setup and start worker + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget); +} + +bool mifare_nested_scene_added_keys_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + } else if(event.type == SceneManagerEventTypeBack) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + + return consumed; +} + +void mifare_nested_scene_added_keys_on_exit(void* context) { + MifareNested* mifare_nested = context; + + widget_reset(mifare_nested->widget); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_check.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_check.c new file mode 100644 index 0000000000..4eb344703e --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_check.c @@ -0,0 +1,102 @@ +#include "../mifare_nested_i.h" + +enum { + MifareNestedSceneCheckStateTagSearch, + MifareNestedSceneCheckStateTagFound, +}; + +bool mifare_nested_check_worker_callback(MifareNestedWorkerEvent event, void* context) { + furi_assert(context); + + MifareNested* mifare_nested = context; + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, event); + + return true; +} + +static void mifare_nested_scene_check_setup_view(MifareNested* mifare_nested) { + Popup* popup = mifare_nested->popup; + popup_reset(popup); + uint32_t state = + scene_manager_get_scene_state(mifare_nested->scene_manager, MifareNestedSceneCheck); + + if(state == MifareNestedSceneCheckStateTagSearch) { + popup_set_icon(mifare_nested->popup, 0, 8, &I_ApplyTag); + popup_set_text( + mifare_nested->popup, "Apply tag to\nthe back", 128, 32, AlignRight, AlignCenter); + } else { + popup_set_icon(popup, 12, 23, &I_Loading); + popup_set_header(popup, "Checking\nDon't move...", 52, 32, AlignLeft, AlignCenter); + } + + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewPopup); +} + +void mifare_nested_scene_check_on_enter(void* context) { + MifareNested* mifare_nested = context; + + scene_manager_set_scene_state( + mifare_nested->scene_manager, + MifareNestedSceneCheck, + MifareNestedSceneCheckStateTagSearch); + mifare_nested_scene_check_setup_view(mifare_nested); + + // Setup and start worker + mifare_nested_worker_start( + mifare_nested->worker, + MifareNestedWorkerStateCheck, + &mifare_nested->nfc_dev->dev_data, + mifare_nested_check_worker_callback, + mifare_nested); + mifare_nested_blink_start(mifare_nested); +} + +bool mifare_nested_scene_check_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == MifareNestedWorkerEventNoncesCollected) { + scene_manager_next_scene( + mifare_nested->scene_manager, MifareNestedSceneNoncesCollected); + consumed = true; + } else if(event.event == MifareNestedWorkerEventAttackFailed) { + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneFailed); + consumed = true; + } else if(event.event == MifareNestedWorkerEventCollecting) { + if(mifare_nested->run == NestedRunAttack) { + if(mifare_nested->settings->only_hardnested) { + FURI_LOG_I("MifareNested", "Using Hard Nested because user settings"); + mifare_nested->collecting_type = MifareNestedWorkerStateCollectingHard; + } + scene_manager_next_scene( + mifare_nested->scene_manager, MifareNestedSceneCollecting); + } else { + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneCheckKeys); + } + consumed = true; + } else if(event.event == MifareNestedWorkerEventNoTagDetected) { + scene_manager_set_scene_state( + mifare_nested->scene_manager, + MifareNestedSceneCheck, + MifareNestedSceneCheckStateTagSearch); + mifare_nested_scene_check_setup_view(mifare_nested); + consumed = true; + } + } + return consumed; +} + +void mifare_nested_scene_check_on_exit(void* context) { + MifareNested* mifare_nested = context; + + mifare_nested_worker_stop(mifare_nested->worker); + scene_manager_set_scene_state( + mifare_nested->scene_manager, + MifareNestedSceneCheck, + MifareNestedSceneCheckStateTagSearch); + // Clear view + popup_reset(mifare_nested->popup); + + mifare_nested_blink_stop(mifare_nested); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_check_keys.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_check_keys.c new file mode 100644 index 0000000000..f0071b7aa6 --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_check_keys.c @@ -0,0 +1,124 @@ +#include "../mifare_nested_i.h" + +void mifare_nested_scene_check_keys_widget_callback( + GuiButtonType result, + InputType type, + void* context) { + MifareNested* mifare_nested = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result); + } +} + +bool mifare_nested_check_keys_worker_callback(MifareNestedWorkerEvent event, void* context) { + MifareNested* mifare_nested = context; + CheckKeysState* plugin_state = mifare_nested->keys_state; + + if(event == MifareNestedWorkerEventKeyChecked) { + mifare_nested_blink_nonce_collection_start(mifare_nested); + + KeyInfo_t* key_info = mifare_nested->keys; + + with_view_model( + plugin_state->view, + CheckKeysViewModel * model, + { + model->lost_tag = false; + model->keys_checked = key_info->checked_keys; + model->keys_found = key_info->found_keys; + model->keys_total = key_info->sector_keys; + model->keys_count = key_info->total_keys; + }, + true); + } else if(event == MifareNestedWorkerEventNoTagDetected) { + mifare_nested_blink_start(mifare_nested); + + with_view_model( + plugin_state->view, CheckKeysViewModel * model, { model->lost_tag = true; }, true); + } else if(event == MifareNestedWorkerEventProcessingKeys) { + with_view_model( + plugin_state->view, + CheckKeysViewModel * model, + { model->processing_keys = true; }, + true); + } + + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, event); + + return true; +} + +void mifare_nested_scene_check_keys_on_enter(void* context) { + MifareNested* mifare_nested = context; + CheckKeysState* plugin_state = mifare_nested->keys_state; + + mifare_nested_worker_start( + mifare_nested->worker, + MifareNestedWorkerStateValidating, + &mifare_nested->nfc_dev->dev_data, + mifare_nested_check_keys_worker_callback, + mifare_nested); + + mifare_nested_blink_start(mifare_nested); + + with_view_model( + plugin_state->view, + CheckKeysViewModel * model, + { + model->lost_tag = false; + model->processing_keys = false; + model->keys_count = 0; + model->keys_checked = 0; + model->keys_found = 0; + }, + false); + + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewCheckKeys); +} + +bool mifare_nested_scene_check_keys_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + + bool consumed = false; + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeCenter) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } else if(event.event == MifareNestedWorkerEventNoncesCollected) { + scene_manager_next_scene( + mifare_nested->scene_manager, MifareNestedSceneNoncesCollected); + consumed = true; + } else if(event.event == MifareNestedWorkerEventNeedKey) { + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneNoKeys); + consumed = true; + } else if(event.event == MifareNestedWorkerEventKeysFound) { + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneAddedKeys); + consumed = true; + } else if(event.event == MifareNestedWorkerEventNeedKeyRecovery) { + scene_manager_next_scene( + mifare_nested->scene_manager, MifareNestedSceneNeedKeyRecovery); + consumed = true; + } else if(event.event == MifareNestedWorkerEventNeedCollection) { + scene_manager_next_scene( + mifare_nested->scene_manager, MifareNestedSceneNeedCollection); + consumed = true; + } else if( + event.event == MifareNestedWorkerEventKeyChecked || + event.event == MifareNestedWorkerEventNoTagDetected || + event.event == MifareNestedWorkerEventProcessingKeys) { + consumed = true; + } + } + + return consumed; +} + +void mifare_nested_scene_check_keys_on_exit(void* context) { + MifareNested* mifare_nested = context; + mifare_nested_worker_stop(mifare_nested->worker); + + // Clear view + mifare_nested_blink_stop(mifare_nested); + popup_reset(mifare_nested->popup); + widget_reset(mifare_nested->widget); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_collecting.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_collecting.c new file mode 100644 index 0000000000..05c96d97df --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_collecting.c @@ -0,0 +1,154 @@ +#include "../mifare_nested_i.h" + +void mifare_nested_scene_collecting_widget_callback( + GuiButtonType result, + InputType type, + void* context) { + MifareNested* mifare_nested = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result); + } +} + +bool mifare_nested_collecting_worker_callback(MifareNestedWorkerEvent event, void* context) { + MifareNested* mifare_nested = context; + NestedState* plugin_state = mifare_nested->nested_state; + + if(event == MifareNestedWorkerEventNewNonce) { + mifare_nested_blink_nonce_collection_start(mifare_nested); + + uint8_t collected = 0; + NonceList_t* nonces = mifare_nested->nonces; + for(uint8_t tries = 0; tries < nonces->tries; tries++) { + for(uint8_t sector = 0; sector < nonces->sector_count; sector++) { + for(uint8_t keyType = 0; keyType < 2; keyType++) { + Nonces* info = nonces->nonces[sector][keyType][tries]; + if(info->collected) { + collected++; + } + } + } + } + + with_view_model( + plugin_state->view, + NestedAttackViewModel * model, + { + model->calibrating = false; + model->lost_tag = false; + model->nonces_collected = collected; + model->keys_count = nonces->sector_count * nonces->tries * 2; + }, + true); + } else if(event == MifareNestedWorkerEventNoTagDetected) { + mifare_nested_blink_start(mifare_nested); + + with_view_model( + plugin_state->view, NestedAttackViewModel * model, { model->lost_tag = true; }, true); + } else if(event == MifareNestedWorkerEventCalibrating) { + mifare_nested_blink_calibration_start(mifare_nested); + + with_view_model( + plugin_state->view, + NestedAttackViewModel * model, + { + model->calibrating = true; + model->lost_tag = false; + model->need_prediction = false; + model->hardnested = false; + }, + true); + } else if(event == MifareNestedWorkerEventNeedPrediction) { + with_view_model( + plugin_state->view, + NestedAttackViewModel * model, + { model->need_prediction = true; }, + true); + } else if(event == MifareNestedWorkerEventHardnestedStatesFound) { + NonceList_t* nonces = mifare_nested->nonces; + with_view_model( + plugin_state->view, + NestedAttackViewModel * model, + { + model->calibrating = false; + model->lost_tag = false; + model->hardnested = true; + model->hardnested_states = nonces->hardnested_states; + }, + true); + } + + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, event); + + return true; +} + +void mifare_nested_scene_collecting_on_enter(void* context) { + MifareNested* mifare_nested = context; + NestedState* nested = mifare_nested->nested_state; + + mifare_nested_worker_start( + mifare_nested->worker, + mifare_nested->collecting_type, + &mifare_nested->nfc_dev->dev_data, + mifare_nested_collecting_worker_callback, + mifare_nested); + + mifare_nested_blink_start(mifare_nested); + + with_view_model( + nested->view, + NestedAttackViewModel * model, + { + model->lost_tag = false; + model->nonces_collected = 0; + }, + false); + + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewCollecting); +} + +bool mifare_nested_scene_collecting_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + + bool consumed = false; + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeCenter) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } else if(event.event == MifareNestedWorkerEventNoncesCollected) { + scene_manager_next_scene( + mifare_nested->scene_manager, MifareNestedSceneNoncesCollected); + consumed = true; + } else if(event.event == MifareNestedWorkerEventAttackFailed) { + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneFailed); + consumed = true; + } else if(event.event == MifareNestedWorkerEventNeedKey) { + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneNoKeys); + consumed = true; + } else if(event.event == MifareNestedWorkerEventStaticEncryptedNonce) { + scene_manager_next_scene( + mifare_nested->scene_manager, MifareNestedSceneStaticEncryptedNonce); + consumed = true; + } else if( + event.event == MifareNestedWorkerEventNewNonce || + event.event == MifareNestedWorkerEventNoTagDetected || + event.event == MifareNestedWorkerEventCalibrating || + event.event == MifareNestedWorkerEventNeedPrediction || + event.event == MifareNestedWorkerEventHardnestedStatesFound) { + consumed = true; + } + } + + return consumed; +} + +void mifare_nested_scene_collecting_on_exit(void* context) { + MifareNested* mifare_nested = context; + mifare_nested_worker_stop(mifare_nested->worker); + + // Clear view + mifare_nested_blink_stop(mifare_nested); + popup_reset(mifare_nested->popup); + widget_reset(mifare_nested->widget); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_config.h b/applications/external/mifare_nested/scenes/mifare_nested_scene_config.h new file mode 100644 index 0000000000..14cf52c4ee --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_config.h @@ -0,0 +1,13 @@ +ADD_SCENE(mifare_nested, start, Start) +ADD_SCENE(mifare_nested, check, Check) +ADD_SCENE(mifare_nested, nonces_collected, NoncesCollected) +ADD_SCENE(mifare_nested, collecting, Collecting) +ADD_SCENE(mifare_nested, no_keys, NoKeys) +ADD_SCENE(mifare_nested, check_keys, CheckKeys) +ADD_SCENE(mifare_nested, added_keys, AddedKeys) +ADD_SCENE(mifare_nested, failed, Failed) +ADD_SCENE(mifare_nested, about, About) +ADD_SCENE(mifare_nested, static_encrypted_nonce, StaticEncryptedNonce) +ADD_SCENE(mifare_nested, need_key_recovery, NeedKeyRecovery) +ADD_SCENE(mifare_nested, need_collection, NeedCollection) +ADD_SCENE(mifare_nested, settings, Settings) \ No newline at end of file diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_failed.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_failed.c new file mode 100644 index 0000000000..e7d1ee80d7 --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_failed.c @@ -0,0 +1,59 @@ +#include "../mifare_nested_i.h" + +void mifare_nested_scene_failed_widget_callback( + GuiButtonType result, + InputType type, + void* context) { + MifareNested* mifare_nested = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result); + } +} + +void mifare_nested_scene_failed_on_enter(void* context) { + MifareNested* mifare_nested = context; + Widget* widget = mifare_nested->widget; + + notification_message(mifare_nested->notifications, &sequence_error); + + widget_add_icon_element(widget, 73, 13, &I_DolphinCry); + widget_add_string_element( + widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "Failed to preform attack"); + widget_add_string_element(widget, 0, 12, AlignLeft, AlignTop, FontSecondary, "Try running"); + widget_add_string_element( + widget, 0, 22, AlignLeft, AlignTop, FontSecondary, "\"Nested attack\""); + widget_add_string_element(widget, 0, 32, AlignLeft, AlignTop, FontSecondary, "again or check"); + widget_add_string_element(widget, 0, 42, AlignLeft, AlignTop, FontSecondary, "logs"); + widget_add_button_element( + widget, + GuiButtonTypeLeft, + "Back", + mifare_nested_scene_failed_widget_callback, + mifare_nested); + + // Setup and start worker + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget); +} + +bool mifare_nested_scene_failed_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + } else if(event.type == SceneManagerEventTypeBack) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + + return consumed; +} + +void mifare_nested_scene_failed_on_exit(void* context) { + MifareNested* mifare_nested = context; + + widget_reset(mifare_nested->widget); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_need_collection.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_need_collection.c new file mode 100644 index 0000000000..ee6e76b40f --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_need_collection.c @@ -0,0 +1,56 @@ +#include "../mifare_nested_i.h" + +void mifare_nested_scene_need_collection_widget_callback( + GuiButtonType result, + InputType type, + void* context) { + MifareNested* mifare_nested = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result); + } +} + +void mifare_nested_scene_need_collection_on_enter(void* context) { + MifareNested* mifare_nested = context; + Widget* widget = mifare_nested->widget; + + notification_message(mifare_nested->notifications, &sequence_error); + + widget_add_icon_element(widget, 73, 13, &I_DolphinCry); + widget_add_string_element( + widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "Missing collected nonces"); + widget_add_string_element( + widget, 0, 12, AlignLeft, AlignTop, FontSecondary, "Run \"Nested attack\""); + widget_add_button_element( + widget, + GuiButtonTypeLeft, + "Back", + mifare_nested_scene_need_collection_widget_callback, + mifare_nested); + + // Setup and start worker + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget); +} + +bool mifare_nested_scene_need_collection_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + } else if(event.type == SceneManagerEventTypeBack) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + + return consumed; +} + +void mifare_nested_scene_need_collection_on_exit(void* context) { + MifareNested* mifare_nested = context; + + widget_reset(mifare_nested->widget); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_need_key_recovery.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_need_key_recovery.c new file mode 100644 index 0000000000..e34b68137e --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_need_key_recovery.c @@ -0,0 +1,59 @@ +#include "../mifare_nested_i.h" + +void mifare_nested_scene_need_key_recovery_widget_callback( + GuiButtonType result, + InputType type, + void* context) { + MifareNested* mifare_nested = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result); + } +} + +void mifare_nested_scene_need_key_recovery_on_enter(void* context) { + MifareNested* mifare_nested = context; + Widget* widget = mifare_nested->widget; + + notification_message(mifare_nested->notifications, &sequence_error); + + widget_add_icon_element(widget, 74, 13, &I_DolphinCry); + widget_add_string_element( + widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "Missing found keys"); + widget_add_string_element( + widget, 0, 12, AlignLeft, AlignTop, FontSecondary, "First you need to"); + widget_add_string_element(widget, 0, 22, AlignLeft, AlignTop, FontSecondary, "recover keys"); + widget_add_string_element(widget, 0, 32, AlignLeft, AlignTop, FontSecondary, "Read \"About\""); + widget_add_string_element(widget, 0, 42, AlignLeft, AlignTop, FontSecondary, "for more info"); + widget_add_button_element( + widget, + GuiButtonTypeLeft, + "Back", + mifare_nested_scene_need_key_recovery_widget_callback, + mifare_nested); + + // Setup and start worker + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget); +} + +bool mifare_nested_scene_need_key_recovery_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + } else if(event.type == SceneManagerEventTypeBack) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + + return consumed; +} + +void mifare_nested_scene_need_key_recovery_on_exit(void* context) { + MifareNested* mifare_nested = context; + + widget_reset(mifare_nested->widget); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_no_keys.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_no_keys.c new file mode 100644 index 0000000000..138cbdbc87 --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_no_keys.c @@ -0,0 +1,61 @@ +#include "../mifare_nested_i.h" + +void mifare_nested_scene_no_keys_widget_callback( + GuiButtonType result, + InputType type, + void* context) { + MifareNested* mifare_nested = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result); + } +} + +void mifare_nested_scene_no_keys_on_enter(void* context) { + MifareNested* mifare_nested = context; + Widget* widget = mifare_nested->widget; + + notification_message(mifare_nested->notifications, &sequence_success); + + widget_add_icon_element(widget, 73, 13, &I_DolphinCry); + widget_add_string_element(widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "No keys found"); + widget_add_string_element( + widget, 0, 12, AlignLeft, AlignTop, FontSecondary, "Scan tag and find at"); + widget_add_string_element( + widget, 0, 22, AlignLeft, AlignTop, FontSecondary, "least one key to"); + widget_add_string_element( + widget, 0, 32, AlignLeft, AlignTop, FontSecondary, "start (save dump"); + widget_add_string_element( + widget, 0, 42, AlignLeft, AlignTop, FontSecondary, "after scanning!)"); + widget_add_button_element( + widget, + GuiButtonTypeLeft, + "Back", + mifare_nested_scene_no_keys_widget_callback, + mifare_nested); + + // Setup and start worker + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget); +} + +bool mifare_nested_scene_no_keys_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + } else if(event.type == SceneManagerEventTypeBack) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + + return consumed; +} + +void mifare_nested_scene_no_keys_on_exit(void* context) { + MifareNested* mifare_nested = context; + + widget_reset(mifare_nested->widget); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_nonces_collected.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_nonces_collected.c new file mode 100644 index 0000000000..cc543645fe --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_nonces_collected.c @@ -0,0 +1,58 @@ +#include "../mifare_nested_i.h" + +void mifare_nested_scene_nonces_collected_widget_callback( + GuiButtonType result, + InputType type, + void* context) { + MifareNested* mifare_nested = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result); + } +} + +void mifare_nested_scene_nonces_collected_on_enter(void* context) { + MifareNested* mifare_nested = context; + Widget* widget = mifare_nested->widget; + + notification_message(mifare_nested->notifications, &sequence_success); + + widget_add_icon_element(widget, 52, 17, &I_DolphinSuccess); + widget_add_string_element(widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "Nonces collected"); + widget_add_string_element( + widget, 0, 12, AlignLeft, AlignTop, FontSecondary, "Now you can run"); + widget_add_string_element(widget, 0, 22, AlignLeft, AlignTop, FontSecondary, "script on your"); + widget_add_string_element(widget, 0, 32, AlignLeft, AlignTop, FontSecondary, "PC to recover"); + widget_add_string_element(widget, 0, 42, AlignLeft, AlignTop, FontSecondary, "keys"); + widget_add_button_element( + widget, + GuiButtonTypeLeft, + "Back", + mifare_nested_scene_nonces_collected_widget_callback, + mifare_nested); + + // Setup and start worker + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget); +} + +bool mifare_nested_scene_nonces_collected_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + } else if(event.type == SceneManagerEventTypeBack) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + + return consumed; +} + +void mifare_nested_scene_nonces_collected_on_exit(void* context) { + MifareNested* mifare_nested = context; + + widget_reset(mifare_nested->widget); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_settings.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_settings.c new file mode 100644 index 0000000000..09d77f94ba --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_settings.c @@ -0,0 +1,65 @@ +#include "../mifare_nested_i.h" +#include + +enum MifareNestedSettingsIndex { MifareNestedIndexBlock, MifareNestedIndexHardNested }; + +#define HARD_NESTED_COUNT 2 +const char* const hard_nested_text[HARD_NESTED_COUNT] = { + "No", + "Yes", +}; + +const bool hard_nested_value[HARD_NESTED_COUNT] = { + false, + true, +}; + +static void mifare_nested_scene_settings_set_hard_nested(VariableItem* item) { + MifareNested* mifare_nested = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + + variable_item_set_current_value_text(item, hard_nested_text[index]); + mifare_nested->settings->only_hardnested = hard_nested_value[index]; +} + +void mifare_nested_scene_settings_on_enter(void* context) { + MifareNested* mifare_nested = context; + VariableItem* item; + uint8_t value_index; + + item = variable_item_list_add( + mifare_nested->variable_item_list, + "Hard Nested only:", + HARD_NESTED_COUNT, + mifare_nested_scene_settings_set_hard_nested, + mifare_nested); + + value_index = value_index_bool( + mifare_nested->settings->only_hardnested, hard_nested_value, HARD_NESTED_COUNT); + + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, hard_nested_text[value_index]); + + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewVariableList); +} + +bool mifare_nested_scene_settings_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == MifareNestedCustomEventSceneSettingLock) { + scene_manager_previous_scene(mifare_nested->scene_manager); + consumed = true; + } + } + + return consumed; +} + +void mifare_nested_scene_settings_on_exit(void* context) { + MifareNested* mifare_nested = context; + variable_item_list_set_selected_item(mifare_nested->variable_item_list, 0); + variable_item_list_reset(mifare_nested->variable_item_list); + scene_manager_set_scene_state(mifare_nested->scene_manager, MifareNestedSceneStart, 0); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_start.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_start.c new file mode 100644 index 0000000000..e8ff25c676 --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_start.c @@ -0,0 +1,84 @@ +#include "../mifare_nested_i.h" +enum SubmenuIndex { + SubmenuIndexCollect, + SubmenuIndexCheck, + SubmenuIndexSettings, + SubmenuIndexAbout +}; + +void mifare_nested_scene_start_submenu_callback(void* context, uint32_t index) { + MifareNested* mifare_nested = context; + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, index); +} + +void mifare_nested_scene_start_on_enter(void* context) { + MifareNested* mifare_nested = context; + + Submenu* submenu = mifare_nested->submenu; + submenu_add_item( + submenu, + "Nested attack", + SubmenuIndexCollect, + mifare_nested_scene_start_submenu_callback, + mifare_nested); + + submenu_add_item( + submenu, + "Check found keys", + SubmenuIndexCheck, + mifare_nested_scene_start_submenu_callback, + mifare_nested); + + submenu_add_item( + submenu, + "Settings", + SubmenuIndexSettings, + mifare_nested_scene_start_submenu_callback, + mifare_nested); + + submenu_add_item( + submenu, + "About", + SubmenuIndexAbout, + mifare_nested_scene_start_submenu_callback, + mifare_nested); + + submenu_set_selected_item( + submenu, + scene_manager_get_scene_state(mifare_nested->scene_manager, MifareNestedSceneStart)); + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewMenu); +} + +bool mifare_nested_scene_start_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubmenuIndexCollect) { + mifare_nested->run = NestedRunAttack; + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneCheck); + consumed = true; + } else if(event.event == SubmenuIndexCheck) { + mifare_nested->run = NestedRunCheckKeys; + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneCheck); + consumed = true; + } else if(event.event == SubmenuIndexSettings) { + mifare_nested->keys->found_keys = 123; + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneSettings); + consumed = true; + } else if(event.event == SubmenuIndexAbout) { + scene_manager_next_scene(mifare_nested->scene_manager, MifareNestedSceneAbout); + consumed = true; + } + + scene_manager_set_scene_state( + mifare_nested->scene_manager, MifareNestedSceneStart, event.event); + } + + return consumed; +} + +void mifare_nested_scene_start_on_exit(void* context) { + MifareNested* mifare_nested = context; + submenu_reset(mifare_nested->submenu); +} diff --git a/applications/external/mifare_nested/scenes/mifare_nested_scene_static_encrypted_nonce.c b/applications/external/mifare_nested/scenes/mifare_nested_scene_static_encrypted_nonce.c new file mode 100644 index 0000000000..92cefa72c3 --- /dev/null +++ b/applications/external/mifare_nested/scenes/mifare_nested_scene_static_encrypted_nonce.c @@ -0,0 +1,58 @@ +#include "../mifare_nested_i.h" + +void mifare_nested_scene_static_encrypted_nonce_widget_callback( + GuiButtonType result, + InputType type, + void* context) { + MifareNested* mifare_nested = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result); + } +} + +void mifare_nested_scene_static_encrypted_nonce_on_enter(void* context) { + MifareNested* mifare_nested = context; + Widget* widget = mifare_nested->widget; + + notification_message(mifare_nested->notifications, &sequence_error); + + widget_add_icon_element(widget, 73, 12, &I_DolphinCry); + widget_add_string_element( + widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "Static encrypted nonce"); + widget_add_string_element(widget, 0, 12, AlignLeft, AlignTop, FontSecondary, "This tag isn't"); + widget_add_string_element(widget, 0, 22, AlignLeft, AlignTop, FontSecondary, "vulnerable to"); + widget_add_string_element(widget, 0, 32, AlignLeft, AlignTop, FontSecondary, "Nested attack"); + + widget_add_button_element( + widget, + GuiButtonTypeLeft, + "Back", + mifare_nested_scene_static_encrypted_nonce_widget_callback, + mifare_nested); + + // Setup and start worker + view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget); +} + +bool mifare_nested_scene_static_encrypted_nonce_on_event(void* context, SceneManagerEvent event) { + MifareNested* mifare_nested = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + } else if(event.type == SceneManagerEventTypeBack) { + scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0); + consumed = true; + } + + return consumed; +} + +void mifare_nested_scene_static_encrypted_nonce_on_exit(void* context) { + MifareNested* mifare_nested = context; + + widget_reset(mifare_nested->widget); +} From c8d396f94bff89309ad71e4cb9ae8decbf0885e9 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 28 May 2023 02:49:29 +0300 Subject: [PATCH 89/92] OFW PR 2680: RFID Add support for Nexkey/Nexwatch by mauimauer --- lib/lfrfid/protocols/lfrfid_protocols.c | 4 +- lib/lfrfid/protocols/lfrfid_protocols.h | 3 +- lib/lfrfid/protocols/protocol_nexwatch.c | 323 +++++++++++++++++++++++ lib/lfrfid/protocols/protocol_nexwatch.h | 4 + 4 files changed, 332 insertions(+), 2 deletions(-) create mode 100644 lib/lfrfid/protocols/protocol_nexwatch.c create mode 100644 lib/lfrfid/protocols/protocol_nexwatch.h diff --git a/lib/lfrfid/protocols/lfrfid_protocols.c b/lib/lfrfid/protocols/lfrfid_protocols.c index 2c1f0ad97c..f07218d7f3 100644 --- a/lib/lfrfid/protocols/lfrfid_protocols.c +++ b/lib/lfrfid/protocols/lfrfid_protocols.c @@ -16,6 +16,7 @@ #include "protocol_pac_stanley.h" #include "protocol_keri.h" #include "protocol_gallagher.h" +#include "protocol_nexwatch.h" const ProtocolBase* lfrfid_protocols[] = { [LFRFIDProtocolEM4100] = &protocol_em4100, @@ -35,4 +36,5 @@ const ProtocolBase* lfrfid_protocols[] = { [LFRFIDProtocolPACStanley] = &protocol_pac_stanley, [LFRFIDProtocolKeri] = &protocol_keri, [LFRFIDProtocolGallagher] = &protocol_gallagher, -}; \ No newline at end of file + [LFRFIDProtocolNexwatch] = &protocol_nexwatch, +}; diff --git a/lib/lfrfid/protocols/lfrfid_protocols.h b/lib/lfrfid/protocols/lfrfid_protocols.h index 848f003a31..0cb7cbc844 100644 --- a/lib/lfrfid/protocols/lfrfid_protocols.h +++ b/lib/lfrfid/protocols/lfrfid_protocols.h @@ -25,6 +25,7 @@ typedef enum { LFRFIDProtocolPACStanley, LFRFIDProtocolKeri, LFRFIDProtocolGallagher, + LFRFIDProtocolNexwatch, LFRFIDProtocolMax, } LFRFIDProtocol; @@ -39,4 +40,4 @@ typedef struct { union { LFRFIDT5577 t5577; }; -} LFRFIDWriteRequest; \ No newline at end of file +} LFRFIDWriteRequest; diff --git a/lib/lfrfid/protocols/protocol_nexwatch.c b/lib/lfrfid/protocols/protocol_nexwatch.c new file mode 100644 index 0000000000..3bbbb42f50 --- /dev/null +++ b/lib/lfrfid/protocols/protocol_nexwatch.c @@ -0,0 +1,323 @@ +#include +#include +#include +#include "lfrfid_protocols.h" + +#define NEXWATCH_PREAMBLE_BIT_SIZE (8) +#define NEXWATCH_PREAMBLE_DATA_SIZE (1) + +#define NEXWATCH_ENCODED_BIT_SIZE (96) +#define NEXWATCH_ENCODED_DATA_SIZE ((NEXWATCH_ENCODED_BIT_SIZE) / 8) + +#define NEXWATCH_DECODED_BIT_SIZE (NEXWATCH_DECODED_DATA_SIZE * 8) +#define NEXWATCH_DECODED_DATA_SIZE (8) + +#define NEXWATCH_US_PER_BIT (255) +#define NEXWATCH_ENCODER_PULSES_PER_BIT (16) + +typedef struct { + uint8_t magic; + char desc[13]; + uint8_t chk; +} ProtocolNexwatchMagic; + +ProtocolNexwatchMagic magic_items[] = { + {0xBE, "Quadrakey", 0}, + {0x88, "Nexkey", 0}, + {0x86, "Honeywell", 0}}; + +typedef struct { + uint8_t data_index; + uint8_t bit_clock_index; + bool last_bit; + bool current_polarity; + bool pulse_phase; +} ProtocolNexwatchEncoder; + +typedef struct { + uint8_t encoded_data[NEXWATCH_ENCODED_DATA_SIZE]; + uint8_t negative_encoded_data[NEXWATCH_ENCODED_DATA_SIZE]; + uint8_t corrupted_encoded_data[NEXWATCH_ENCODED_DATA_SIZE]; + uint8_t corrupted_negative_encoded_data[NEXWATCH_ENCODED_DATA_SIZE]; + + uint8_t data[NEXWATCH_DECODED_DATA_SIZE]; + ProtocolNexwatchEncoder encoder; +} ProtocolNexwatch; + +ProtocolNexwatch* protocol_nexwatch_alloc(void) { + ProtocolNexwatch* protocol = malloc(sizeof(ProtocolNexwatch)); + return protocol; +}; + +void protocol_nexwatch_free(ProtocolNexwatch* protocol) { + free(protocol); +}; + +uint8_t* protocol_nexwatch_get_data(ProtocolNexwatch* protocol) { + return protocol->data; +}; + +void protocol_nexwatch_decoder_start(ProtocolNexwatch* protocol) { + memset(protocol->encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE); + memset(protocol->negative_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE); + memset(protocol->corrupted_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE); + memset(protocol->corrupted_negative_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE); +}; + +static bool protocol_nexwatch_check_preamble(uint8_t* data, size_t bit_index) { + // 01010110 + if(bit_lib_get_bits(data, bit_index, 8) != 0b01010110) return false; + return true; +} + +static uint8_t protocol_nexwatch_parity_swap(uint8_t parity) { + uint8_t a = (((parity >> 3) & 1)); + a |= (((parity >> 1) & 1) << 1); + a |= (((parity >> 2) & 1) << 2); + a |= ((parity & 1) << 3); + return a; +} + +static uint8_t protocol_nexwatch_parity(const uint8_t hexid[5]) { + uint8_t p = 0; + for(uint8_t i = 0; i < 5; i++) { + p ^= ((hexid[i]) & 0xF0) >> 4; + p ^= ((hexid[i]) & 0x0F); + } + return protocol_nexwatch_parity_swap(p); +} + +static uint8_t protocol_nexwatch_checksum(uint8_t magic, uint32_t id, uint8_t parity) { + uint8_t a = ((id >> 24) & 0xFF); + a -= ((id >> 16) & 0xFF); + a -= ((id >> 8) & 0xFF); + a -= (id & 0xFF); + a -= magic; + a -= (bit_lib_reverse_8_fast(parity) >> 4); + return bit_lib_reverse_8_fast(a); +} + +static bool protocol_nexwatch_can_be_decoded(uint8_t* data) { + if(!protocol_nexwatch_check_preamble(data, 0)) return false; + + // Check for reserved word (32-bit) + if(bit_lib_get_bits_32(data, 8, 32) != 0) { + return false; + } + + uint8_t parity = bit_lib_get_bits(data, 76, 4); + + // parity check + // from 32b hex id, 4b mode + uint8_t hex[5] = {0}; + for(uint8_t i = 0; i < 5; i++) { + hex[i] = bit_lib_get_bits(data, 40 + (i * 8), 8); + } + //mode is only 4 bits. + hex[4] &= 0xf0; + uint8_t calc_parity = protocol_nexwatch_parity(hex); + + if(calc_parity != parity) { + return false; + } + + return true; +} + +static bool protocol_nexwatch_decoder_feed_internal(bool polarity, uint32_t time, uint8_t* data) { + time += (NEXWATCH_US_PER_BIT / 2); + + size_t bit_count = (time / NEXWATCH_US_PER_BIT); + bool result = false; + + if(bit_count < NEXWATCH_ENCODED_BIT_SIZE) { + for(size_t i = 0; i < bit_count; i++) { + bit_lib_push_bit(data, NEXWATCH_ENCODED_DATA_SIZE, polarity); + if(protocol_nexwatch_can_be_decoded(data)) { + result = true; + break; + } + } + } + + return result; +} + +static void protocol_nexwatch_descramble(uint32_t* id, uint32_t* scrambled) { + // 255 = Not used/Unknown other values are the bit offset in the ID/FC values + const uint8_t hex_2_id[] = {31, 27, 23, 19, 15, 11, 7, 3, 30, 26, 22, 18, 14, 10, 6, 2, + 29, 25, 21, 17, 13, 9, 5, 1, 28, 24, 20, 16, 12, 8, 4, 0}; + + *id = 0; + for(uint8_t idx = 0; idx < 32; idx++) { + bool bit_state = (*scrambled >> hex_2_id[idx]) & 1; + *id |= (bit_state << (31 - idx)); + } +} + +static void protocol_nexwatch_decoder_save(uint8_t* data_to, const uint8_t* data_from) { + uint32_t id = bit_lib_get_bits_32(data_from, 40, 32); + data_to[4] = (uint8_t)id; + data_to[3] = (uint8_t)(id >>= 8); + data_to[2] = (uint8_t)(id >>= 8); + data_to[1] = (uint8_t)(id >>= 8); + data_to[0] = (uint8_t)(id >>= 8); + uint32_t check = bit_lib_get_bits_32(data_from, 72, 24); + data_to[7] = (uint8_t)check; + data_to[6] = (uint8_t)(check >>= 8); + data_to[5] = (uint8_t)(check >>= 8); +} + +bool protocol_nexwatch_decoder_feed(ProtocolNexwatch* protocol, bool level, uint32_t duration) { + bool result = false; + + if(duration > (NEXWATCH_US_PER_BIT / 2)) { + if(protocol_nexwatch_decoder_feed_internal(level, duration, protocol->encoded_data)) { + protocol_nexwatch_decoder_save(protocol->data, protocol->encoded_data); + result = true; + return result; + } + + if(protocol_nexwatch_decoder_feed_internal( + !level, duration, protocol->negative_encoded_data)) { + protocol_nexwatch_decoder_save(protocol->data, protocol->negative_encoded_data); + result = true; + return result; + } + } + + if(duration > (NEXWATCH_US_PER_BIT / 4)) { + // Try to decode wrong phase synced data + if(level) { + duration += 120; + } else { + if(duration > 120) { + duration -= 120; + } + } + + if(protocol_nexwatch_decoder_feed_internal( + level, duration, protocol->corrupted_encoded_data)) { + protocol_nexwatch_decoder_save(protocol->data, protocol->corrupted_encoded_data); + + result = true; + return result; + } + + if(protocol_nexwatch_decoder_feed_internal( + !level, duration, protocol->corrupted_negative_encoded_data)) { + protocol_nexwatch_decoder_save( + protocol->data, protocol->corrupted_negative_encoded_data); + + result = true; + return result; + } + } + + return result; +}; + +bool protocol_nexwatch_encoder_start(ProtocolNexwatch* protocol) { + memset(protocol->encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE); + *(uint32_t*)&protocol->encoded_data[0] = 0b00000000000000000000000001010110; + bit_lib_copy_bits(protocol->encoded_data, 32, 32, protocol->data, 0); + bit_lib_copy_bits(protocol->encoded_data, 64, 32, protocol->data, 32); + + protocol->encoder.last_bit = + bit_lib_get_bit(protocol->encoded_data, NEXWATCH_ENCODED_BIT_SIZE - 1); + protocol->encoder.data_index = 0; + protocol->encoder.current_polarity = true; + protocol->encoder.pulse_phase = true; + protocol->encoder.bit_clock_index = 0; + + return true; +}; + +LevelDuration protocol_nexwatch_encoder_yield(ProtocolNexwatch* protocol) { + LevelDuration level_duration; + ProtocolNexwatchEncoder* encoder = &protocol->encoder; + + if(encoder->pulse_phase) { + level_duration = level_duration_make(encoder->current_polarity, 1); + encoder->pulse_phase = false; + } else { + level_duration = level_duration_make(!encoder->current_polarity, 1); + encoder->pulse_phase = true; + + encoder->bit_clock_index++; + if(encoder->bit_clock_index >= NEXWATCH_ENCODER_PULSES_PER_BIT) { + encoder->bit_clock_index = 0; + + bool current_bit = bit_lib_get_bit(protocol->encoded_data, encoder->data_index); + + if(current_bit != encoder->last_bit) { + encoder->current_polarity = !encoder->current_polarity; + } + + encoder->last_bit = current_bit; + + bit_lib_increment_index(encoder->data_index, NEXWATCH_ENCODED_BIT_SIZE); + } + } + + return level_duration; +}; + +void protocol_nexwatch_render_data(ProtocolNexwatch* protocol, FuriString* result) { + uint32_t id = 0; + uint32_t scrambled = bit_lib_get_bits_32(protocol->data, 8, 32); + protocol_nexwatch_descramble(&id, &scrambled); + + uint8_t m_idx; + uint8_t mode = bit_lib_get_bits(protocol->data, 40, 4); + uint8_t parity = bit_lib_get_bits(protocol->data, 44, 4); + uint8_t chk = bit_lib_get_bits(protocol->data, 48, 8); + for(m_idx = 0; m_idx < 3; m_idx++) { + magic_items[m_idx].chk = protocol_nexwatch_checksum(magic_items[m_idx].magic, id, parity); + if(magic_items[m_idx].chk == chk) { + break; + } + } + furi_string_printf(result, "ID: %lu, M:%u\r\nType: %s\r\n", id, mode, magic_items[m_idx].desc); +} + +bool protocol_nexwatch_write_data(ProtocolNexwatch* protocol, void* data) { + LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data; + bool result = false; + + protocol_nexwatch_encoder_start(protocol); + if(request->write_type == LFRFIDWriteTypeT5577) { + request->t5577.block[0] = LFRFID_T5577_MODULATION_PSK1 | LFRFID_T5577_BITRATE_RF_32 | + (3 << LFRFID_T5577_MAXBLOCK_SHIFT); + request->t5577.block[1] = bit_lib_get_bits_32(protocol->encoded_data, 0, 32); + request->t5577.block[2] = bit_lib_get_bits_32(protocol->encoded_data, 32, 32); + request->t5577.block[3] = bit_lib_get_bits_32(protocol->encoded_data, 64, 32); + request->t5577.blocks_to_write = 4; + result = true; + } + return result; +}; + +const ProtocolBase protocol_nexwatch = { + .name = "Nexwatch", + .manufacturer = "Honeywell", + .data_size = NEXWATCH_DECODED_DATA_SIZE, + .features = LFRFIDFeaturePSK, + .validate_count = 6, + .alloc = (ProtocolAlloc)protocol_nexwatch_alloc, + .free = (ProtocolFree)protocol_nexwatch_free, + .get_data = (ProtocolGetData)protocol_nexwatch_get_data, + .decoder = + { + .start = (ProtocolDecoderStart)protocol_nexwatch_decoder_start, + .feed = (ProtocolDecoderFeed)protocol_nexwatch_decoder_feed, + }, + .encoder = + { + .start = (ProtocolEncoderStart)protocol_nexwatch_encoder_start, + .yield = (ProtocolEncoderYield)protocol_nexwatch_encoder_yield, + }, + .render_data = (ProtocolRenderData)protocol_nexwatch_render_data, + .render_brief_data = (ProtocolRenderData)protocol_nexwatch_render_data, + .write_data = (ProtocolWriteData)protocol_nexwatch_write_data, +}; diff --git a/lib/lfrfid/protocols/protocol_nexwatch.h b/lib/lfrfid/protocols/protocol_nexwatch.h new file mode 100644 index 0000000000..0872ca7dcd --- /dev/null +++ b/lib/lfrfid/protocols/protocol_nexwatch.h @@ -0,0 +1,4 @@ +#pragma once +#include + +extern const ProtocolBase protocol_nexwatch; From a11b6e72dcbe8873136952c7c8a0953fdd418ae6 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 28 May 2023 03:53:54 +0300 Subject: [PATCH 90/92] Update changelog and readme + some small fixes --- CHANGELOG.md | 22 +++++++++++++++++-- ReadMe.md | 7 +++--- .../external/mifare_nested/application.fam | 2 +- .../desktop/scenes/desktop_scene_main.c | 4 +++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23e815ba98..0c4943faa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,38 @@ ### New changes +* !!! **Warning! After installing, Desktop settings (Favoutite apps, PIN Code, AutoLock time..) will be resetted to default due to settings changes, Please set your PIN code, Favourite apps again in Settings->Desktop** !!! +* If you have copied any apps manually into `apps` folder - remove `apps` folder or that specific apps you copied on your microSD before installing this release to avoid issues due to OFW API version update! If you using regular builds or extra pack builds (e) without your manually added apps, all included apps will be installed automatically, no extra actions needed! +----- +* Desktop: **Show clock on main screen** (Enable in Settings->Desktop->Show Clock) (by @gid9798 | PR #484) +* SubGHz Remote: New plugin - Configurator (Remote Maker) - Now you can create and edit map files on flipper! (by @gid9798 | PR #487) * SubGHz Remote: Full refactoring, app was re-made from scratch (by @gid9798) +* Archive: Fix rename, show error message to user * API: Cleanup, mini refactoring of some apps (+6k of free flash space) * SubGHz: Various fixes (by @gid9798) * SubGHz: Fix counter settings in debug * SubGHz: Move dangerous_settings check (by @gid9798 | PR #475) +* Misc: Move NFC plugins into NFC folder * Misc: Name changer code moved to proper place, load after system startup + extra checks +* Plugins: Merge tiktok and ytshorts remote into one (by @Willy-JL) * Plugins: NMEA GPS UART - stability fix * Plugins: Port XFW keyboard with extra symbols to WiFi Marauder instead of using UART Term keyboard (thanks to @Willy-JL) -* Plugins: Update NMEA GPS UART [(by ezod)](https://github.com/ezod/flipperzero-gps) +* Plugins: Moved from extra pack to main FW: Mifare Nested [(by AloneLiberty)](https://github.com/AloneLiberty/FlipperNested) - Works with PC and python app `FlipperNested` +* Plugins: Update TOTP (Authenticator) [(by akopachov)](https://github.com/akopachov/flipper-zero_authenticator) (+ Add option to set custom fonts) +* Plugins: Update NMEA GPS UART [(by ezod)](https://github.com/ezod/flipperzero-gps) (GLL support) * Plugins: Update WiFi Marauder [(by 0xchocolate)](https://github.com/0xchocolate/flipperzero-firmware-with-wifi-marauder-companion) +* OFW PR 2680: RFID - Add support for Nexkey/Nexwatch (by @mauimauer) +* OFW: nfc: Mifare Ultralight C detection +* OFW: api: added toolbox/api_lock.h +* OFW: NFC: Add support for Gen4 "ultimate card" in Magic app +* OFW: desktop: Refactor favorites settings and allow app browser in selection +* OFW: Infrared: respect carrier frequency and duty cycle settings -> **Breaking API change, API version was changed from 26.x to 27.x** +* OFW: Desktop,Rpc: desktop status subscription +* OFW: Storage, common_rename: check that old path is exists * OFW: Services: remove deallocator for persistent services * OFW: Storage: common_rename is now POSIX compliant * OFW: Removed user-specific data from tar artifacts * OFW: fbt: Fix tar uid overflow when packaging * OFW: fbt: Use union for old py (Fix builds if using older python versions) -* OFW PR 2682: USB HID report timeout (by nminaylov) +* OFW: USB HID report timeout #### [🎲 Download latest extra apps pack](https://github.com/xMasterX/all-the-plugins/archive/refs/heads/main.zip) diff --git a/ReadMe.md b/ReadMe.md index e25896a23f..9b6947e906 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -45,6 +45,7 @@ Our Discord Community: * Universal remote for Projectors, Fans, A/Cs and Audio(soundbars, etc.) * Customizable Flipper name **Update! Now can be changed in Settings->Desktop** (by @xMasterX and @Willy-JL) * Text Input UI element -> Cursor feature (by @Willy-JL) +- **BadBT** plugin (BT version of BadKB) [(by Willy-JL, ClaraCrazy, XFW contributors)](https://github.com/ClaraCrazy/Flipper-Xtreme/tree/dev/applications/main/bad_kb) - (See in Applications->Tools) - (aka BadUSB via Bluetooth) - BadUSB -> Keyboard layouts [(by rien > dummy-decoy)](https://github.com/dummy-decoy/flipperzero-firmware/tree/dummy_decoy/bad_usb_keyboard_layout) - Sub-GHz -> External CC1101 module support - [(by quen0n)](https://github.com/DarkFlippers/unleashed-firmware/pull/307) - Sub-GHz -> `Add manually` menu extended with new protocols @@ -164,8 +165,8 @@ You can support us by using links or addresses below: - **ProtoView** [(by antirez)](https://github.com/antirez/protoview) - **SWD Probe** [(by g3gg0)](https://github.com/g3gg0/flipper-swd_probe) - IR Scope [(by kallanreed)](https://github.com/DarkFlippers/unleashed-firmware/pull/407) -- BadBT plugin (BT version of BadKB) [(by Willy-JL, ClaraCrazy, XFW contributors)](https://github.com/ClaraCrazy/Flipper-Xtreme/tree/dev/applications/main/bad_kb) -- [Flipper (Mifare) Nested (by AloneLiberty)](https://github.com/AloneLiberty/FlipperNested) - Works with PC and python app `FlipperNested` +- **BadBT** plugin (BT version of BadKB) [(by Willy-JL, ClaraCrazy, XFW contributors)](https://github.com/ClaraCrazy/Flipper-Xtreme/tree/dev/applications/main/bad_kb) (See in Applications->Tools) - (aka BadUSB via Bluetooth) +- **Mifare Nested** [(by AloneLiberty)](https://github.com/AloneLiberty/FlipperNested) - Works with PC and python app `FlipperNested` Games: - DOOM (fixed) [(by p4nic4ttack)](https://github.com/p4nic4ttack/doom-flipper-zero/) @@ -194,7 +195,7 @@ Games: ## [- How to change Flipper name](https://github.com/DarkFlippers/unleashed-firmware/blob/dev/documentation/CustomFlipperName.md) -## [- How to use (Mifare) Nested plugin to recover keys](https://github.com/AloneLiberty/FlipperNested#how-to-use-it) +## [- How to use Mifare Nested plugin to recover keys](https://github.com/AloneLiberty/FlipperNested#how-to-use-it) ### **Sub-GHz** diff --git a/applications/external/mifare_nested/application.fam b/applications/external/mifare_nested/application.fam index 9bebd9fd83..236abf6d17 100644 --- a/applications/external/mifare_nested/application.fam +++ b/applications/external/mifare_nested/application.fam @@ -1,6 +1,6 @@ App( appid="mifare_nested", - name="Flipper (Mifare) Nested", + name="Mifare Nested", apptype=FlipperAppType.EXTERNAL, entry_point="mifare_nested_app", requires=[ diff --git a/applications/services/desktop/scenes/desktop_scene_main.c b/applications/services/desktop/scenes/desktop_scene_main.c index 79f17fee7f..3d1b16c57a 100644 --- a/applications/services/desktop/scenes/desktop_scene_main.c +++ b/applications/services/desktop/scenes/desktop_scene_main.c @@ -82,7 +82,9 @@ static void desktop_scene_main_start_favorite(Desktop* desktop, FavoriteApp* app } else if(strlen(application->name_or_path) > 0) { status = loader_start(desktop->loader, application->name_or_path, NULL); } else { - status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, NULL); + // No favourite app is set! So we skipping this part + return; + //status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, NULL); } if(status != LoaderStatusOk) { From 1e1b85a5758e7055d0fb248af8e2ee9a9277167b Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 28 May 2023 04:18:32 +0300 Subject: [PATCH 91/92] SecPlus 2.0 - Add new custom button Fix issue with add manually --- CHANGELOG.md | 1 + lib/subghz/protocols/secplus_v2.c | 34 +++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c4943faa9..0bdc1ffcb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * SubGHz Remote: Full refactoring, app was re-made from scratch (by @gid9798) * Archive: Fix rename, show error message to user * API: Cleanup, mini refactoring of some apps (+6k of free flash space) +* SubGHz: Security+ 2.0 -> add extra custom button `0x78` - Fixes issue #469 * SubGHz: Various fixes (by @gid9798) * SubGHz: Fix counter settings in debug * SubGHz: Move dangerous_settings check (by @gid9798 | PR #475) diff --git a/lib/subghz/protocols/secplus_v2.c b/lib/subghz/protocols/secplus_v2.c index d39f794ab4..7acfb74acc 100644 --- a/lib/subghz/protocols/secplus_v2.c +++ b/lib/subghz/protocols/secplus_v2.c @@ -345,7 +345,7 @@ static void if(subghz_custom_btn_get_original() == 0) { subghz_custom_btn_set_original(instance->btn); } - subghz_custom_btn_set_max(3); + subghz_custom_btn_set_max(4); } /** @@ -377,7 +377,7 @@ static uint64_t subghz_protocol_secplus_v2_encode_half(uint8_t roll_array[], uin /** * Defines the button value for the current btn_id - * Basic set | 0x68 | 0x80 | 0x81 | 0xE2 | + * Basic set | 0x68 | 0x80 | 0x81 | 0xE2 | 0x78 * @return Button code */ static uint8_t subghz_protocol_secplus_v2_get_btn_code(); @@ -856,6 +856,9 @@ static uint8_t subghz_protocol_secplus_v2_get_btn_code() { case 0xE2: btn = 0x80; break; + case 0x78: + btn = 0x80; + break; default: break; @@ -874,6 +877,9 @@ static uint8_t subghz_protocol_secplus_v2_get_btn_code() { case 0xE2: btn = 0x81; break; + case 0x78: + btn = 0x81; + break; default: break; @@ -892,6 +898,30 @@ static uint8_t subghz_protocol_secplus_v2_get_btn_code() { case 0xE2: btn = 0x68; break; + case 0x78: + btn = 0xE2; + break; + + default: + break; + } + } else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_RIGHT) { + switch(original_btn_code) { + case 0x68: + btn = 0x78; + break; + case 0x80: + btn = 0x78; + break; + case 0x81: + btn = 0x78; + break; + case 0xE2: + btn = 0x78; + break; + case 0x78: + btn = 0x68; + break; default: break; From 0d1fea986121a34d644589b2bf9b7389b56e476d Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 28 May 2023 06:36:19 +0300 Subject: [PATCH 92/92] LFRFID PSK Raws in debug --- CHANGELOG.md | 1 + applications/main/lfrfid/lfrfid.c | 7 +++---- .../lfrfid/scenes/lfrfid_scene_raw_emulate.c | 19 +++---------------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bdc1ffcb6..425ba63002 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * SubGHz Remote: Full refactoring, app was re-made from scratch (by @gid9798) * Archive: Fix rename, show error message to user * API: Cleanup, mini refactoring of some apps (+6k of free flash space) +* LFRFID: Debug: Allow PSK RAW emulation in gui * SubGHz: Security+ 2.0 -> add extra custom button `0x78` - Fixes issue #469 * SubGHz: Various fixes (by @gid9798) * SubGHz: Fix counter settings in debug diff --git a/applications/main/lfrfid/lfrfid.c b/applications/main/lfrfid/lfrfid.c index a82d2dd034..8030d785d7 100644 --- a/applications/main/lfrfid/lfrfid.c +++ b/applications/main/lfrfid/lfrfid.c @@ -252,8 +252,7 @@ bool lfrfid_load_raw_key_from_file_select(LfRfid* app) { furi_assert(app); DialogsFileBrowserOptions browser_options; - dialog_file_browser_set_basic_options( - &browser_options, LFRFID_APP_RAW_ASK_EXTENSION, &I_125_10px); + dialog_file_browser_set_basic_options(&browser_options, ".raw", &I_125_10px); browser_options.base_path = LFRFID_APP_FOLDER; // Input events and views are managed by file_browser @@ -261,9 +260,9 @@ bool lfrfid_load_raw_key_from_file_select(LfRfid* app) { dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options); if(result) { - // Extract .raw and then .ask + // Extract .raw path_extract_filename(app->file_path, app->file_name, true); - path_extract_filename(app->file_name, app->file_name, true); + //path_extract_filename(app->file_name, app->file_name, true); } return result; diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_raw_emulate.c b/applications/main/lfrfid/scenes/lfrfid_scene_raw_emulate.c index c06a5eebfc..11fa25744a 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_raw_emulate.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_raw_emulate.c @@ -3,7 +3,6 @@ #define TAG "ADC" typedef struct { - FuriString* string_file_name; bool error; } LfRfidEmulateRawState; @@ -23,26 +22,15 @@ void lfrfid_scene_raw_emulate_on_enter(void* context) { LfRfidEmulateRawState* state = malloc(sizeof(LfRfidEmulateRawState)); scene_manager_set_scene_state(app->scene_manager, LfRfidSceneRawEmulate, (uint32_t)state); - state->string_file_name = furi_string_alloc(); popup_set_icon(popup, 0, 3, &I_RFIDDolphinReceive_97x61); view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup); lfrfid_worker_start_thread(app->lfworker); lfrfid_make_app_folder(app); - furi_string_printf( - state->string_file_name, - "%s/%s%s", - LFRFID_SD_FOLDER, - furi_string_get_cstr(app->file_name), - LFRFID_APP_RAW_ASK_EXTENSION); - FURI_LOG_D(TAG, "raw_emulate->file_name=%s", furi_string_get_cstr(state->string_file_name)); - popup_set_header(popup, "Emulating\nRAW RFID\nASK", 89, 30, AlignCenter, AlignTop); + popup_set_header(popup, "Emulating\nRAW RFID", 89, 30, AlignCenter, AlignTop); lfrfid_worker_emulate_raw_start( - app->lfworker, - furi_string_get_cstr(state->string_file_name), - lfrfid_raw_emulate_callback, - app); + app->lfworker, furi_string_get_cstr(app->file_path), lfrfid_raw_emulate_callback, app); notification_message(app->notifications, &sequence_blink_start_cyan); @@ -63,7 +51,7 @@ bool lfrfid_scene_raw_emulate_on_event(void* context, SceneManagerEvent event) { consumed = true; state->error = true; popup_set_header( - popup, "Reading\nRAW RFID\nFile error", 89, 30, AlignCenter, AlignTop); + popup, "Emulating\nRAW RFID\nFile error", 89, 30, AlignCenter, AlignTop); notification_message(app->notifications, &sequence_blink_start_red); } } @@ -81,6 +69,5 @@ void lfrfid_scene_raw_emulate_on_exit(void* context) { lfrfid_worker_stop(app->lfworker); lfrfid_worker_stop_thread(app->lfworker); - furi_string_free(state->string_file_name); free(state); }