加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MainTask.c 184.60 KB
一键复制 编辑 原始数据 按行查看 历史
尹生 提交于 2020-08-07 15:59 . 单次播放后不能播放的问题
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085
/*
*********************************************************************************************************
**********************************************************************************************************/
#include "stm32f10x.h"
#include "includes.h"
#include "MainTask.h"
#include "DIALOG.h"
#include "stm32f10x_adc.h"
#include "bsp_ili9341_lcd.h"
#include <stdio.h>
#include<string.h>
#include "common.h"
#include "DIALOG.h"
#include "spi_flash.h"
#include "stm32f10x_crc.h"
#define speaker ListIndex[MENU_home]
enum {
ID_WINDOW_0 = GUI_ID_USER
,ID_StutusBar
, ID_BUTTON_LOGO //logo2
//hotkey
, ID_BUTTON_HOTKEY1 //hotkey1
, ID_BUTTON_HOTKEY2 //hotkey2
, ID_BUTTON_HOTKEY3 //hotkey3
, ID_BUTTON_HOTKEY4 //hotkey4
//顶部状态栏
, ID_TOPstatus_Dogg1
, ID_TOPstatus_Dogg2
, ID_TOPstatus_Dogg3
, ID_TOPstatus_Decoy
, ID_TOPstatus_TimerL
, ID_TOPstatus_TimerR
, ID_TOPstatus_Battery
//speaker 连接状态
, ID_BUTTON_DoggIconL1
, ID_TEXT_DoggFileName_L1
, ID_BUTTON_Signal_L1
, ID_BUTTON_BatLevel_L1
, ID_TEXT_DoggIDl_L1
, ID_BUTTON_Speaker_L1
, ID_TEXT_DoggVol_L1
, ID_BUTTON_DoggIconL2
, ID_TEXT_DoggFileName_L2
, ID_BUTTON_Signal_L2
, ID_BUTTON_BatLevel_L2
, ID_TEXT_DoggIDl_L2
, ID_BUTTON_Speaker_L2
, ID_TEXT_DoggVol_L2
, ID_BUTTON_DoggIconL3
, ID_TEXT_DoggFileName_L3
, ID_BUTTON_Signal_L3
, ID_BUTTON_BatLevel_L3
, ID_TEXT_DoggIDl_L3
, ID_BUTTON_Speaker_L3
, ID_TEXT_DoggVol_L3
//三角符号
, ID_BUTTON_TRI_Right //dot
, ID_BUTTON_TRI_UP //up
, ID_BUTTON_TRI_DOWN //down
//窗口内容
, ID_TEXT_TITLE
, ID_TEXT_SubTITLE
, ID_TEXT_0
, ID_TEXT_1
, ID_TEXT_2
, ID_BUTTON_USER0
, ID_BUTTON_USER1
, ID_BUTTON_USER2
, ID_BUTTON_USER3
, ID_BUTTON_USER4
, ID_BUTTON_USER5
, ID_BUTTON_USER6
, ID_BUTTON_USER7
, ID_LISTBOX_USER0
, ID_LISTBOX_USER1
, ID_LISTBOX_USER2
, ID_LISTBOX_USER3
, ID_LISTBOX_USER4
, ID_LISTBOX_USER5
, ID_EDITBOX_USER0
, ID_SLIDER_SVOL
, ID_SLIDER_TVOL
, ID_SCROLL_BRIGHT
, ID_PROGRESS
, ID_DROPDOWN_0
//expH
, ID_BUTTON_EXPH_Left
, ID_BUTTON_EXPH_Mid
, ID_BUTTON_EXPH_Right
};
#define SPEED 1000
#define ADC_Battery(Volt) ((u16)((float)(Volt*4096*91)/(3.3*(91+75))))
//#define ADC_STEP0 ADC_Battery(1.25*3)
#define ADC_STEP1 ADC_Battery(1.30*3)
#define ADC_STEP2 ADC_Battery(1.34*3)
#define ADC_STEP3 ADC_Battery(1.38*3)
#define ADC_STEP4 ADC_Battery(1.42*3)
u8 Speaker_selected=0;
u16 offset_status_bar_ypx,offset_list_ypx;
path_type current_path[Max_depth];
u8 folderdeep;
u16 current_play_node;
u16 adc_bat;
vu16 global_node=0xffff;
u8 playing_expert=0;
u8 selected_itemexpert=0;
u8 sync_only_read=0;
u8 toggle_allOff = 0;
u8 ListIndex[MENU_MAX];
u8 special_render=0;
u8 playing=0;
vu32 address_mem_speaker=0;
u8 btn_horz = 0;
u8 btn_low = 1;
u8 stop_out=0;
struct {
u8 type;
u16 node;
}list_attr[256];
u8 flag_hunt_index;
WM_HWIN first_window;//开机窗口
WM_HWIN main_window;//主窗口
WM_HWIN Status_bar;//状态栏
WM_HWIN ListItem_doggs;//
WM_HWIN MainTitle;//标题栏
WM_HWIN SubTitle;//标题栏2
WM_HWIN Logo_window;//
WM_HWIN ListItem;//菜单
WM_HWIN ListItem2;//弹出菜单
WM_HWIN doggSelectIcon;
WM_HWIN ScrollUpWin;//三角形
WM_HWIN ScrollDownWin;//三角形
WM_HWIN TopStatusWin[7];//顶部
WM_HWIN doggsWin[Doggs_Display_MAX][7];//dogg列表内
WM_HWIN Btnexp[3];// expert Hunt下方三个按钮
WM_HWIN BtnHotkey[4];//热键
WM_HWIN BtnWin[8];//按钮
WM_HWIN TextWin[4];
WM_HWIN EditWin1;//编辑
WM_HWIN ScrollWin;//滚动条
WM_HWIN ProgWin;//进度条
WM_HWIN hKeyboard;//键盘
WM_HWIN WIN_SLIDER_BASS ;//低音调整
WM_HWIN WIN_SLIDER_TREBLE;//高音调整
WM_HWIN genBtn;
WM_HWIN ListItem3;
WM_HWIN listExperts;
WM_HWIN listFavorites;
u8 menu_page=0; //菜单编号
u8 last_menu=0;
u8 ActiveDoggsNumber;//状态栏当前显示dogg的数目
DOGG_Type dogg[Doggs_List_MAX];
DOGG_Type * current_dogg;
DOGG_registed registed_dogg[Doggs_REG_MAX];
u8 decoy_link;
u8 decoy_speed;
u8 timer_enable;
u8 brightness;
u16 size_tree;
const GUI_FONT * pFnt;
struct
{
u8 state;
const GUI_BITMAP * icon;
const char *text;
const char *btnA;
const char *btnB;
const char *SubText;
} DialogMssgX;
u8 result_dialog=0;
u8 sub_expert_menu=0;
u8 hunt_filesNumber=0;
u8 toAll = 0;
u16 tmp_expert[EpertHunt_MAX];
u8 tmp_expert_idx=0;
u8 mode_EP_navigation=1;
u8 speaker_toLink=0;
u8 linking_tree =0;
u8 list2_funtion=0;//文件子菜单
u8 reading_mode_option= 0;
union {
u16 int_data;
u8 bytes[2];
} size_tree_un;
union {
u16 int_data;
u8 bytes[2];
} dir_serial_tree;
u8 decoy_linked;
u8 pMenu=0xff;
u8 sec=0;
u16 min=0;
u8 flag_disable_list;
u8 flag_transmitting,tx_waiting;
u8 current_menu=0;
info_sound_type sound_info={0,0,0,0};
extern volatile u16 time_ms,time_key,delay_ms;
extern vu8 buffer_count;
extern vu8 uart2_rx_buffer[];
u8 flag_power;//0:关,1:背光关,2:正常
u16 display_time;
u8 line_start;
u8 decoy_sn[6];
char decoy_ver[20];
#define MainMenuHideItem (ActiveDoggsNumber ==0 || (current_dogg->setting & STATE_BT_MASK))
/********************************
以下变量需要保存到 FLASH
********************************/
Save2Flash main_coff;
const char * hotkey_string(u8 index)
{
const char *p;
switch(index)
{
case HotKey_PlaySound:
p= "Play\nSound";
break;
case HotKey_AllOff:
p= "All\nOff";
break;
case HotKey_NightMode:
p="Night\nMode";
break;
case HotKey_SettingsMenu:
p="Settings\nMenu";
break;
case HotKey_MainMenu:
p="Main\nMenu";
break;
#ifdef HotKey_SpeakerVolume
case HotKey_SpeakerVolume:
p= "Speaker\nVolume";
break;
#endif
#ifdef HotKey_SpeakerSelection
case HotKey_SpeakerSelection:
p="Speaker\nSelection";
break;
#endif
default:
p="--";
break;
}
return p;
}
__inline u32 address_tree(u8 idx_spk,u32 offset)
{
if(idx_spk >= Doggs_REG_MAX)return (u32)(-1);
return (u32)((idx_spk*(DOGG_MEMORY_SIZE))+offset);
}
u8 LCD_brightness;
void set_brightness(u8 bright)
{
LCD_brightness = bright;
if(bright != 0 && bright < 5)bright=5;//最低亮度
else if(bright >100)bright=100;
TIM_SetCompare1(TIM3,bright*bright);
}
u32 get_color_NightMode(u8 itum)
{
GUI_COLOR tmp;
u8 mode=main_coff.night_mode;
switch (itum)
{
case COLOR_Title_BACK:
tmp = (mode)?(((u32)0<<16)|(0<<8)|0) : GUI_BLACK;
break;
case COLOR_TITLE_TEXT:
tmp = GUI_WHITE;
break;
default :
case COLOR_BACK:
tmp = (mode)?(((u32)50<<16)|(50<<8)|50) : GUI_LIGHTGRAY;
break;
case COLOR_ListItem_BACK:
tmp = (mode)?GUI_BLACK : GUI_LIGHTGRAY;
break;
case COLOR_BAR:
tmp = (mode)? (((u32)102<<16)|(153<<8)|255) : 0x002079f4;
break;
case COLOR_BTN_SELECTED:
tmp = (mode)?(((u32)106<<16)|(153<<8)|255) : 0x002079f4;
break;
case COLOR_BTN_UNSEL:
tmp = GUI_WHITE;
break;
case COLOR_EditBox_Back:
tmp = (mode)?0x00505050:0x00909090;
break;
case COLOR_TEXT_LIST:
tmp = (mode)?GUI_WHITE : GUI_BLACK;
break;
case COLOR_ListItem_UNFORCE:
tmp = (mode)?(((u32)32<<16)|(32<<8)|32):GUI_GRAY;
break;
case COLOR_ListItem_DISABLE:
tmp = (mode)?0x00404040:0x00909090;
break;
case COLOR_ListItem_UNSEL:
tmp = (mode)?(((u32)25<<16)|(25<<8)|25) : GUI_LIGHTGRAY;
break;
case COLOR_ListItem_SELECTED:
tmp = (mode)?(((u32)50<<16)|(50<<8)|50) : GUI_DARKGREEN;
break;
case COLOR_ListItem1_UNSEL:
tmp = (mode)?(((u32)152<<16)|(173<<8)|214) : (((u32)157<<16)|(197<<8)|255);
break;
case COLOR_ListItem1_SELECTED:
tmp = (mode)?(((u32)92<<16)|(132<<8)|214) : (((u32)77<<16)|(148<<8)|246);
break;
case COLOR_ListItem2_UNSEL:
tmp = (mode)?(((u32)16<<16)|(16<<8)|16) : 0x00b0b0b0;
break;
}
return tmp;
}
GUI_CONST_STORAGE GUI_FONT * get_fontSize(u8 size)
{
GUI_CONST_STORAGE GUI_FONT *p;
switch(main_coff.font_size)
{
case 0://small
switch(size)
{
default:
p= &GUI_FontKlavikaBasic22;
break;
case 1:
p= &GUI_FontKlavikaBasic24;
break;
case 2:
p= &GUI_FontSheepmanRegular28;
break;
}
break;
case 1:
switch(size)
{
default:
p= &GUI_FontKlavikaBasic24;
break;
case 1:
p= &GUI_FontKlavikaBasic28;
break;
case 2:
p= &GUI_FontSheepmanRegular32;
break;
}
break;
default:
switch(size)
{
default:
p= &GUI_FontKlavikaBasic24;
break;
case 1:
p= &GUI_FontKlavikaBasic28;
break;
case 2:
p= &GUI_FontSheepmanRegular32;
break;
}
break;
}
return p;
}
u8 id_to_spk(u16 id_in)
{
u8 k;
DOGG_Type *p = dogg;
for(k=0;k<Doggs_List_MAX;k++)
{
if(p->ID == id_in && p->doggtype != 0xff)return k;
p++;
}
return 0xff;
}
u8 id_to_FlashIndex(u16 id_in)
{
u8 k;
DOGG_registed * p = registed_dogg;
for(k=0;k<Doggs_REG_MAX;k++)
{
if(p->ID == id_in && p->doggtype != 0xff)return k;
p++;
}
return 0xff;
}
u8 task1_state;
u16 task1_delay;
u16 Search_progress;
u8 searching_mode=1;
u8 New_icon_state;
char text_keyboard[30];
u8 keyboard_en=0;
u8 frame_created=0; //用于未进入画面时,禁止刷新图标
u8 scroll_pos=0; //用于显示三角
u8 max_element=0; //用于显示三角
u8 size_element=24; //用于显示三角
/*********************************************************************
* //开机画面
* _FRMCreate
**********************************************************************/
static const GUI_WIDGET_CREATE_INFO _FRMCreate[] = {
{ WINDOW_CreateIndirect, NULL, GUI_ID_USER, 0, 0, 240, 320, 0, 0x0, 0 },//图片
{ TEXT_CreateIndirect, "Connecting to Master Device", GUI_ID_USER+1, 0, 170, 240, 50, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Searching...", GUI_ID_USER+2, 0, 220, 240, 30, 0, 0x0, 0 },
{ LISTBOX_CreateIndirect, NULL, GUI_ID_USER+4, 0, 260, 240, 48, 0, 0x0, 0 },
{ PROGBAR_CreateIndirect, NULL, GUI_ID_USER+3, 20, 205, 200, 15, 0, 0x0, 0 }
};
/*********************************************************************
* 屏幕键盘
* _aDialogKeypad
************************************************************************/
static const GUI_WIDGET_CREATE_INFO _aDialogKeypad[] = {
{ WINDOW_CreateIndirect, NULL, ID_WINDOW_0, 0, 135, 240, 145, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "1", GUI_ID_USER + 1, 1, 2, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "2", GUI_ID_USER + 2, 25, 2, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "3", GUI_ID_USER + 3, 49, 2, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "4", GUI_ID_USER + 4, 73, 2, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "5", GUI_ID_USER + 5, 97, 2, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "6", GUI_ID_USER + 6, 121, 2, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "7", GUI_ID_USER + 7, 145, 2, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "8", GUI_ID_USER + 8, 169, 2, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "9", GUI_ID_USER + 9, 193, 2, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "0", GUI_ID_USER + 10, 217, 2, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Q", GUI_ID_USER + 11, 1, 36, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "W", GUI_ID_USER + 12, 25, 36, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "E", GUI_ID_USER + 13, 49, 36, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "R", GUI_ID_USER + 14, 73, 36, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "T", GUI_ID_USER + 15, 97, 36, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Y", GUI_ID_USER + 16, 121, 36, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "U", GUI_ID_USER + 17, 145, 36, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "I", GUI_ID_USER + 18, 169, 36, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "O", GUI_ID_USER + 19, 193, 36, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "P", GUI_ID_USER + 20, 217, 36, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "A", GUI_ID_USER + 21, 1, 70, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "S", GUI_ID_USER + 22, 25, 70, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "D", GUI_ID_USER + 23, 49, 70, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "F", GUI_ID_USER + 24, 73, 70, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "G", GUI_ID_USER + 25, 97, 70, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "H", GUI_ID_USER + 26, 121, 70, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "J", GUI_ID_USER + 27, 145, 70, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "K", GUI_ID_USER + 28, 169, 70, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "L", GUI_ID_USER + 29, 193, 70, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "\x08", GUI_ID_USER + 30, 217, 70, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Z", GUI_ID_USER + 31, 1, 104, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "X", GUI_ID_USER + 32, 25, 104, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "C", GUI_ID_USER + 33, 49, 104, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "V", GUI_ID_USER + 34, 73, 104, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "B", GUI_ID_USER + 35, 97, 104, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "N", GUI_ID_USER + 36, 121, 104, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "M", GUI_ID_USER + 37, 145, 104, 21, 29, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, " ", GUI_ID_USER + 38, 170, 104, 21, 28, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "\x0d", GUI_ID_USER + 39, 194, 104, 42, 28, 0, 0x0, 0 },//Enter
//{ BUTTON_CreateIndirect, "#", GUI_ID_USER + 30, 209, 68, 20, 20, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
//对话窗
static const GUI_WIDGET_CREATE_INFO _aDialogUser[] = {
{ WINDOW_CreateIndirect, "", ID_WINDOW_0, 60, 60, 120, 160, 0x0, 0 },
{ BUTTON_CreateIndirect, "", GUI_ID_USER + 1, 12, 5, 96, 96 },
{ TEXT_CreateIndirect, "", GUI_ID_USER + 2, 5, 106, 115, 40},
{ BUTTON_CreateIndirect, "Ok", GUI_ID_USER + 3, 10, 151, 50, 20 },
{ BUTTON_CreateIndirect, "Cancel", GUI_ID_USER + 4, 70, 151, 50, 20 },
{ TEXT_CreateIndirect, "Creating...", GUI_ID_USER + 5, 5, 151, 115, 20 },
};
//主界面
#define STATUS_BAR_MID (STATUS_BAR_Y/2)
#define DOGG1_Y (STATUS_BAR_Y+DOGGS_BAR_Y/2)
#define DOGG2_Y (DOGG1_Y+DOGGS_BAR_Y)
#define DOGG3_Y (DOGG2_Y+DOGGS_BAR_Y)
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
/* Function Text Id Px, Py, Dx,Dy */
{ WINDOW_CreateIndirect, NULL, ID_WINDOW_0, 0, 0, 240, 320, 0, 0x0, 0 },//主窗口
{ TEXT_CreateIndirect, NULL, ID_StutusBar, 0, 0, 240, STATUS_BAR_Y, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_TITLE, 0, STATUS_BAR_Y, 240, 40, 0, 0x0, 0 },//标题
{ TEXT_CreateIndirect, NULL, ID_TEXT_SubTITLE, 0, STATUS_BAR_Y*2, 240, 40, 0, 0x0, 0 },//标题2
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_LOGO, 0, STATUS_BAR_Y, 240, 240, 0, 0x0, 0 },
//hotkey
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_HOTKEY1, 0, 280, 60, 40, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_HOTKEY2, 60, 280, 60, 40, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_HOTKEY3, 120, 280, 60, 40, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_HOTKEY4, 180, 280, 60, 40, 0, 0x0, 0 },
{ LISTBOX_CreateIndirect, NULL, ID_LISTBOX_USER1, 0, STATUS_BAR_Y, 240, 60, 0, 0x0, 0 },//dogg
{ LISTBOX_CreateIndirect, NULL, ID_LISTBOX_USER0, 0, STATUS_BAR_Y, 240, 240, 0, 0x0, 0 },//main
{ TEXT_CreateIndirect, NULL, ID_TEXT_0, 75, 175, 25, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_1, 75, 200, 25, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_2, 0, 280-32, 240, 32, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL,ID_BUTTON_USER0, 60, 120, 25, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL,ID_BUTTON_USER1, 90, 120, 25, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL,ID_BUTTON_USER2, 120, 120, 25, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL,ID_BUTTON_USER3, 150, 120, 25, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL,ID_BUTTON_USER4, 180, 120, 25, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL,ID_BUTTON_USER5, 210, 120, 25, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL,ID_BUTTON_USER6, 120, 120, 40, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL,ID_BUTTON_USER7, 180, 90, 40, 20, 0, 0x0, 0 },
{ SCROLLBAR_CreateIndirect, NULL, ID_SCROLL_BRIGHT, 80, 186, 140, 15, 0, 0x0, 0 },
{ PROGBAR_CreateIndirect, NULL, ID_PROGRESS, 10, 210, 220, 15, 0, 0x0, 0 },
{ SLIDER_CreateIndirect, NULL,ID_SLIDER_SVOL, 100, 175, 60, 20, 0, 0x0, 0 },
{ SLIDER_CreateIndirect, NULL,ID_SLIDER_TVOL, 100, 200, 60, 20, 0, 0x0, 0 },
//状态栏
{ BUTTON_CreateIndirect, NULL, ID_TOPstatus_Dogg1, 5, STATUS_BAR_MID-9, 20, 18, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_TOPstatus_Dogg2, 30, STATUS_BAR_MID-9, 20, 18, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_TOPstatus_Dogg3, 55, STATUS_BAR_MID-9, 20, 18, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_TOPstatus_Decoy, 80, STATUS_BAR_MID-9, 20, 18, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "0:00", ID_TOPstatus_TimerL, 126, STATUS_BAR_MID-10, 40, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "0:00", ID_TOPstatus_TimerR, 165, STATUS_BAR_MID-10, 40, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_TOPstatus_Battery, 202, STATUS_BAR_MID-7, 28, 15, 0, 0x0, 0 },
//第一行
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_DoggIconL1, 22, DOGG1_Y-9, 20, 18, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_DoggFileName_L1, 35, DOGG1_Y-9, 50, 18, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_Signal_L1, 100, DOGG1_Y-9, 25, 18, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_BatLevel_L1, 140, DOGG1_Y-7, 28, 15, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_DoggIDl_L1, 175, DOGG1_Y-10, 31, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_Speaker_L1, 210, DOGG1_Y-10, 10, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_DoggVol_L1, 215, DOGG1_Y-10, 26, 21, 0, 0x0, 0 },
//第二行
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_DoggIconL2, 22, DOGG2_Y-9, 20, 18, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_DoggFileName_L2, 35, DOGG2_Y-9, 50, 18, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_Signal_L2, 100, DOGG2_Y-9, 25, 18, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_BatLevel_L2, 140, DOGG2_Y-7, 28, 15, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_DoggIDl_L2, 175, DOGG2_Y-10, 31, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_Speaker_L2, 210, DOGG2_Y-10, 10, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_DoggVol_L2, 215, DOGG2_Y-10, 26, 21, 0, 0x0, 0 },
//第三行
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_DoggIconL3, 22, DOGG3_Y-9, 20, 18, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_DoggFileName_L3, 35, DOGG3_Y-9, 50, 18, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_Signal_L3, 100, DOGG3_Y-9, 25, 18, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_BatLevel_L3, 140, DOGG3_Y-7, 28, 15, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_Speaker_L3, 210, DOGG3_Y-10, 10, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_DoggIDl_L3, 175, DOGG3_Y-10, 31, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, NULL, ID_TEXT_DoggVol_L3, 215, DOGG3_Y-10, 26, 21, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "\x75", ID_BUTTON_TRI_Right, 2, DOGG1_Y-10, 19, 20, 0, 0x0, 0 },//播放三角符号
{ TEXT_CreateIndirect, "\x70", ID_BUTTON_TRI_UP, 222, 80, 18, 16, 0, 0x0, 0 },//上三角形
{ TEXT_CreateIndirect, "\x71", ID_BUTTON_TRI_DOWN, 222, 261, 18, 16, 0, 0x0, 0 },//下三角形
{ LISTBOX_CreateIndirect, NULL, ID_LISTBOX_USER2, 0, 208, 240, 72, 0, 0x0, 0 },//play
{ LISTBOX_CreateIndirect, NULL, ID_LISTBOX_USER3, 0, 80, 240, 160, 0, 0x0, 0 },
{ LISTBOX_CreateIndirect, NULL, ID_LISTBOX_USER4, 0, 206, 240, 74, 0, 0x0, 0 },
{ LISTBOX_CreateIndirect, NULL, ID_LISTBOX_USER5, 0, 206, 240, 74, 0, 0x0, 0 },
{ EDIT_CreateIndirect, NULL, ID_EDITBOX_USER0, 100, 84, 182, 24, 0, 0x0, 0 },
//expH页下方3个选择按钮
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_EXPH_Left, 0, 250, 80, 30, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_EXPH_Mid, 80, 250, 80, 30, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, NULL, ID_BUTTON_EXPH_Right, 160, 250, 80, 30, 0, 0x0, 0 },
};
//交互对话窗口
static void _cbDialogUser(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
u32 color_windows=0;
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG:
if(main_coff.night_mode)
{
color_windows =(((u32)94<<16)|(108<<8)|107);
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 2);
TEXT_SetTextColor(hItem,GUI_WHITE);
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 5);
TEXT_SetTextColor(hItem, GUI_WHITE);
}
else
{
color_windows =(((u32)174<<16)|(250<<8)|245);
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 2);
TEXT_SetTextColor(hItem, GUI_BLACK);
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 5);
TEXT_SetTextColor(hItem, GUI_BLACK);
}
WINDOW_SetBkColor(pMsg->hWin, color_windows);
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 3);
BUTTON_SetText(hItem,DialogMssgX.btnA);
BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED ,get_color_NightMode(COLOR_ListItem_UNSEL));
BUTTON_SetTextColor(hItem,BUTTON_CI_PRESSED ,get_color_NightMode(COLOR_ListItem_SELECTED));
WM_HideWindow(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 4);
BUTTON_SetText(hItem,DialogMssgX.btnB);
BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED ,get_color_NightMode(COLOR_ListItem_UNSEL));
BUTTON_SetTextColor(hItem,BUTTON_CI_PRESSED ,get_color_NightMode(COLOR_ListItem_SELECTED));
WM_HideWindow(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 2);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_HCENTER);
TEXT_SetFont(hItem, GUI_FONT_16_1);
TEXT_SetText(hItem,DialogMssgX.text);
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 5);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_HCENTER);
TEXT_SetFont(hItem, GUI_FONT_16_1);
TEXT_SetText(hItem,DialogMssgX.SubText);
WM_HideWindow(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 1);
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,DialogMssgX.icon,0,0);
BUTTON_SetPressed(hItem,0);
BUTTON_SetBkColor(hItem, BUTTON_CI_UNPRESSED, color_windows);
WM_SetFocus(hItem);
break;
case WM_NOTIFY_PARENT:
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
//弹出交互对话窗口
void Dialog_Now(GUI_CONST_STORAGE GUI_BITMAP * icon,const char * TextIn)
{
WM_HWIN win;
DialogMssgX.icon=icon;
DialogMssgX.text=TextIn;
DialogMssgX.state=1;
win = GUI_CreateDialogBox(_aDialogUser,GUI_COUNTOF(_aDialogUser),_cbDialogUser, WM_HBKWIN, 0, 0);
GUI_Delay(2000);
GUI_EndDialog(win,0);
}
//屏幕键盘
static void _cbDialogKeypad(WM_MESSAGE * pMsg)
{
int i;
WM_HWIN hItem;
switch (pMsg->MsgId)
{
case WM_PAINT:
break;
case WM_INIT_DIALOG:
WINDOW_SetBkColor(pMsg->hWin, (((u32)67<<16)|(67<<8)|67));
for (i = 1; i < 40; i++) {
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + i);
//BUTTON_SetBitmapEx(hItem,BUTTON_BI_PRESSED,&bmtop,0,0);
if(i==30)
{
BUTTON_SetBitmapEx(hItem,BUTTON_BI_PRESSED,&bmdel_selected,0,0);
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,&bmdel,0,0);
}
else if(i==38)
{
BUTTON_SetBitmapEx(hItem,BUTTON_BI_PRESSED,&bmnspace_pressed,0,0);
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,&bmnspace,0,0);
}
else if(i==39)
{
BUTTON_SetBitmapEx(hItem,BUTTON_BI_PRESSED,&bmnenter_pressed,0,0);
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,&bmnenter,0,0);
}
else
{
BUTTON_SetBitmapEx(hItem,BUTTON_BI_PRESSED,&bmkey_released,0,0);
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,&bmkey,0,0);
}
BUTTON_SetTextColor(hItem, BUTTON_CI_PRESSED, GUI_WHITE);
BUTTON_SetTextColor(hItem, BUTTON_CI_UNPRESSED, GUI_WHITE);
BUTTON_SetFont(hItem,GUI_FONT_16_ASCII);
}
break;
case WM_NOTIFY_PARENT:
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
//开机画面窗口
static void _FRM_FirstPage(WM_MESSAGE * pMsg)
{
GUI_COLOR Color,Color_back,Color_btn,Color_btnUnSel;
WM_HWIN hItem;
switch (pMsg->MsgId)
{
case WM_PAINT:
if(main_coff.night_mode)
{
GUI_DrawBitmap(&bmlogo2,20,60);
}
else
{
GUI_DrawBitmap(&bmlogo,20,60);
}
break;
case WM_INIT_DIALOG:
//开机画面背景颜色
if(main_coff.night_mode)
{
Color= GUI_WHITE;
Color_back= (((u32)50<<16)|(50<<8)|50);
Color_btn = (((u32)60<<16)|(60<<8)|60);
Color_btnUnSel= (((u32)40<<16)|(40<<8)|40);
}
else
{
Color= GUI_BLACK;
Color_back= (((u32)210<<16)|(210<<8)|210);
Color_btn = GUI_DARKGREEN;
Color_btnUnSel= (((u32)220<<16)|(220<<8)|220);
}
WINDOW_SetBkColor(pMsg->hWin, Color_back);
//文字1
TextWin[0]=hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER+1);
TEXT_SetTextAlign(hItem, GUI_TA_HCENTER);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
TEXT_SetTextColor(hItem, Color);
//文字2
TextWin[1]= hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER+2);
TEXT_SetTextAlign(hItem, GUI_TA_HCENTER);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
TEXT_SetTextColor(hItem, Color);
//选择按钮
ListItem= hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER+4);
LISTBOX_SetTextAlign(hItem, GUI_TA_HCENTER);
LISTBOX_SetFont(hItem, &GUI_FontKlavikaBasic24);
LISTBOX_SetTextColor(hItem,LISTBOX_CI_SELFOCUS,Color);
LISTBOX_SetTextColor(hItem,LISTBOX_CI_UNSEL,Color);
//LISTBOX_SetTextColor(hItem,LISTBOX_CI_DISABLED,Color_back);
LISTBOX_SetBkColor(hItem,LISTBOX_CI_SELFOCUS, Color_btn);
LISTBOX_SetBkColor(hItem,LISTBOX_CI_UNSEL, Color_btnUnSel);
//LISTBOX_SetBkColor(hItem,LISTBOX_CI_DISABLED,Color_back);
LISTBOX_AddString(hItem, "Go!");
LISTBOX_SetSel(hItem,0);
WM_HideWindow(hItem);
//进度条
ProgWin= hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER+3);
PROGBAR_SetValue(ProgWin, 0);
WM_HideWindow(hItem);
break;
case WM_NOTIFY_PARENT:
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
GUI_CONST_STORAGE GUI_BITMAP * get_icon_battery(u8 step)
{
GUI_CONST_STORAGE GUI_BITMAP * icon;
step &= 0x07;
switch(step)
{
default:
icon= &bmbatt5;
break;
case 2:
icon= &bmbatt4;
break;
case 3:
icon= &bmbatt3;
break;
case 4:
icon= &bmbatt2;
break;
case 5:
icon= &bmbatt1;
break;
}
return icon;
}
void show_bat_icon(void)
{
u8 level;
if(adc_bat>=ADC_STEP4)level=5;
else if(adc_bat>=ADC_STEP3)level=4;
else if(adc_bat>ADC_STEP2)level=3;
else if(adc_bat>=ADC_STEP1)level=2;
#ifdef ADC_STEP0
else if(adc_bat<ADC_STEP0)level=0;
#endif
else
level=1;
BUTTON_SetBitmapEx(TopStatusWin[4],BUTTON_BI_UNPRESSED,get_icon_battery(level),0,0);
}
GUI_CONST_STORAGE GUI_BITMAP * get_doggTypeIcon(DOGG_Type * p_dogg,u8 mode)
{
GUI_CONST_STORAGE GUI_BITMAP * p;
if(p_dogg->MemState == 0xff)p_dogg->MemState =0;
switch(p_dogg->doggtype)
{
case TOP_DOGG:
if((p_dogg->MemState & Dogg_ONLINE_MASK)||mode)
p=&bmtop1;
else
p=&bmtop;
break;
case HORN_DOGG:
if((p_dogg->MemState & Dogg_ONLINE_MASK)||mode)
p=&bmhorn1;
else
p=&bmhorn;
break;
case TRIPLE_DOGG:
if((p_dogg->MemState & Dogg_ONLINE_MASK)||mode)
p=&bmtrip1;
else
p=&bmtrip;
break;
default:
p=&bmempty;
break;
}
return p;
}
void refresh_arrows(s8 flag)
{
vu16 tmp16;
u16 list_select;
u8 Max;
const GUI_FONT * pFnt;
Max = LISTBOX_GetNumItems(ListItem);
if(menu_page == MENU_GoPage || Max < 4)return;
list_select = LISTBOX_GetSel(ListItem);
pFnt = (const GUI_FONT *)LISTBOX_GetFont(ListItem);
size_element = pFnt->YSize+LISTBOX_GetItemSpacing(ListItem);
tmp16 = WM_GetWindowSizeY(ListItem);
max_element = tmp16/size_element;
tmp16 %= size_element;
tmp16 = (320-40-19)-tmp16;
if(flag == 1)//down
{
if(list_select==0)
scroll_pos=0;
else if(list_select > (scroll_pos+(max_element-1)))
scroll_pos++;
}
else if(flag == -1)//up
{
if(list_select < scroll_pos)
scroll_pos = list_select;
else if(list_select > (scroll_pos+(max_element-1)))
scroll_pos = list_select-(max_element-1);
}
if(scroll_pos)
{
WM_ShowWindow(ScrollUpWin);
}
else
{
WM_HideWindow(ScrollUpWin);
}
if((Max > max_element)&&(scroll_pos < (Max-max_element))&&(!list2_funtion))
{
WM_ShowWindow(ScrollDownWin);
}
else
{
WM_HideWindow(ScrollDownWin);
}
}
u8 pActiveSpeakerNumber=0;
u8 check_dogg_online(DOGG_Type * p_dogg, u8 mask)
{
u8 ret=0;
if(p_dogg->doggtype >= TOP_DOGG && p_dogg->doggtype<= TRIPLE_DOGG && p_dogg->ID != 0xffff && p_dogg->ID != 0)
{
ret |= Dogg_REGISTED_MASK;
if(p_dogg->status & STATUS_POWER_MASK)ret |= STATUS_POWER_MASK;
if(p_dogg->MemState & Dogg_ONLINE_MASK)ret |= Dogg_ONLINE_MASK;
}
return (ret & mask);
}
__inline u8 get_active_spk(void)
{
u8 i,tmp;
tmp=0;
for(i=0;i<Doggs_List_MAX;i++)
{
if(check_dogg_online(&dogg[i],STATUS_POWER_MASK))tmp++;
}
return tmp;
}
__inline void resize_spk_lits(u8 size_list)
{
vu8 tmp;
tmp =LISTBOX_GetNumItems(ListItem_doggs);
while(tmp!=size_list)
{
if(tmp>size_list)
{
LISTBOX_DeleteItem(ListItem_doggs,--tmp);
}
else
{
LISTBOX_AddString(ListItem_doggs, "");
tmp++;
}
}
}
u16 show_one_bar=0;
void resize_allWindows(void)
{
u8 height;
if(main_coff.font_size==0)
height=24+8;
else if(main_coff.font_size==1)
height=28+8;
else
height=32+8;
ActiveDoggsNumber = get_active_spk();
offset_status_bar_ypx = (ActiveDoggsNumber*20)+STATUS_BAR_Y;//计算窗口位置
offset_list_ypx = offset_status_bar_ypx+height;
WM_SetWindowPos(ListItem_doggs,0,STATUS_BAR_Y,240,(ActiveDoggsNumber*20));
WM_SetWindowPos(MainTitle,0, offset_status_bar_ypx, 240, height);
WM_SetWindowPos(ListItem, 0, offset_list_ypx, 240, 280-offset_list_ypx);
WM_SetWindowPos(ScrollUpWin, 222, offset_list_ypx, 18, 16);
}
void re_size_windows_all(void)
{
vu8 tmp,i,j,only_show;
u16 tmp16;
resize_allWindows();
if(!(current_dogg->status & STATUS_POWER_MASK))
{
for(i=(Doggs_List_MAX-1);i>0;i--){
if((check_dogg_online(&dogg[i],STATUS_POWER_MASK))&&(!show_one_bar))break;
}
current_dogg = &dogg[i];
}
tmp16=current_dogg->ID;
arrange_dogg(show_one_bar);
resize_spk_lits(ActiveDoggsNumber);
tmp=id_to_spk(tmp16);
current_dogg = &dogg[tmp];
LISTBOX_SetSel(ListItem_doggs,tmp);
ListIndex[MENU_home]=tmp;
set_icon_backcolor(ListIndex[MENU_home]);
if(ActiveDoggsNumber)
WM_ShowWindow(doggSelectIcon);//右三角
else
WM_HideWindow(doggSelectIcon);
WM_SetWindowPos(doggSelectIcon,2, 41+(ListIndex[MENU_home]*20), 20, 19);
resize_allWindows();
refresh_arrows(0);
if(menu_page == MENU_MainMenu){
if(!MainMenuHideItem){
LISTBOX_SetItemDisabled(ListItem, 0, 0);
LISTBOX_SetItemDisabled(ListItem, 1, 0);
}
}
New_icon_state |=0x07;
}
void icon_refresh(u8 mode_in )
{
vu8 tmp,i,j,only_show;
u8 dogg_index;
u16 id0;
char strbuf[16];
WM_HWIN hItem;
volatile unsigned short heigth_icon;
GUI_CONST_STORAGE GUI_BITMAP * icon;
if(!frame_created)return;
if(searching_mode != 0)return;
ActiveDoggsNumber = get_active_spk();
if(!ActiveDoggsNumber)show_one_bar=0;
if(show_one_bar)
{
ActiveDoggsNumber = 1;
}
if((ActiveDoggsNumber!=pActiveSpeakerNumber)||(mode_in))
{
re_size_windows_all();
}
if(show_one_bar)
{
id0 = current_dogg->ID;
if(id0 == 0xffff)return;
only_show = id_to_spk(current_dogg->ID);
New_icon_state |=0x07;
}
if((ActiveDoggsNumber!=pActiveSpeakerNumber)||(New_icon_state & 0x07)||show_one_bar||(mode_in))
{
dogg_index =0;
for(j=0;j < Doggs_Display_MAX;j++)
{
if(check_dogg_online(&dogg[j],STATUS_POWER_MASK))
{
//状态栏
icon = get_doggTypeIcon(&dogg[j],1);
hItem = TopStatusWin[dogg_index];
WM_SetWindowPos(hItem, 5+j*25, STATUS_BAR_MID+9 - icon->YSize,icon->XSize,icon->YSize);
BUTTON_SetBitmap(hItem,BUTTON_BI_UNPRESSED,icon);
WM_ShowWindow(hItem);
//列表栏
hItem = doggsWin[dogg_index][0];
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,icon,0,0);
WM_SetWindowPos(hItem, 18, (DOGG1_Y+9) +j*20 - icon->YSize,icon->XSize,icon->YSize);
WM_ShowWindow(hItem);
hItem = doggsWin[dogg_index][1];
WM_ShowWindow(hItem);
hItem = doggsWin[j][2];
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,&bmwifi1,0,0);
WM_ShowWindow(hItem);
hItem = doggsWin[dogg_index][3];
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,get_icon_battery(dogg[j].status),0,0);
WM_ShowWindow(hItem);
hItem = doggsWin[dogg_index][4];
sprintf(strbuf, "%04X",dogg[j].ID);
TEXT_SetText(hItem, strbuf);
WM_ShowWindow(hItem);
hItem = doggsWin[dogg_index][5];
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,&bmlabar,0,0);
WM_ShowWindow(hItem);
hItem = doggsWin[dogg_index][6];
sprintf(strbuf,"%d",dogg[j].main_volume);
TEXT_SetText(hItem,strbuf);
WM_ShowWindow(hItem);
dogg_index++;
}
}
//隐藏已显示后关机的dogg
j= dogg_index;
while(j < Doggs_Display_MAX)
{
for(i=0;i<7;i++){
WM_HideWindow(doggsWin[dogg_index][i]);
}
j++;
}
#ifdef DECOY_SETTING
//显示decoy
if(decoy_linked)
{
icon = &bmdecy1;
heigth_icon = icon->YSize;
hItem = TopStatusWin[dogg_index];
WM_SetYSize(hItem,heigth_icon);
WM_MoveTo(hItem, 5+dogg_index*25, STATUS_BAR_MID+9 - heigth_icon);
BUTTON_SetBitmap(hItem,BUTTON_BI_UNPRESSED,icon);
WM_ShowWindow(hItem);
dogg_index++;
}
#endif
//隐藏后面的
while(dogg_index < (Doggs_Display_MAX+1))//decoy占一个位置
{
WM_HideWindow(TopStatusWin[dogg_index++]);
}
//dogg选择三角
dogg_index = 0;
for(i=0;i<Doggs_Display_MAX;i++)
{
if((check_dogg_online(&dogg[i],STATUS_POWER_MASK))&&(id0 == dogg[i].ID))
{
dogg_index = i;
break;
}
}
speaker = dogg_index;
//改变颜色
set_icon_backcolor(speaker);
pActiveSpeakerNumber=ActiveDoggsNumber;
}
New_icon_state = 0;
}
/*********************************************************************
*
* _cbDialog
* 主页面
*********************************************************************/
static void _cbDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
char strbuf[16];
u8 i;
u8 tmp,type;
u8 titile_height;
GUI_CONST_STORAGE GUI_BITMAP * icon;
u32 back_color,color;
switch (pMsg->MsgId)
{
case WM_PAINT:
//GUI_Clear();
break;
case WM_INIT_DIALOG:
ActiveDoggsNumber = get_active_spk();
if(main_coff.font_size==0)
titile_height=24+8;
else if(main_coff.font_size==1)
titile_height=28+8;
else
titile_height=32+8;
offset_status_bar_ypx = (ActiveDoggsNumber*20)+STATUS_BAR_Y;//计算窗口位置
offset_list_ypx = offset_status_bar_ypx+titile_height;
//////////////////////////////////////////////////////////////////////
//LOGO
back_color = get_color_NightMode(COLOR_BACK);
WINDOW_SetBkColor(pMsg->hWin, back_color);
Status_bar = WM_GetDialogItem(pMsg->hWin, ID_StutusBar);
Logo_window = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_LOGO);
BUTTON_SetBkColor(Logo_window,BUTTON_BI_UNPRESSED,back_color);
if(main_coff.night_mode){
TEXT_SetBkColor(Status_bar,(((u32)106<<16)|(153<<8)|255));
BUTTON_SetBitmapEx(Logo_window,BUTTON_BI_UNPRESSED,&bmlogo2,20,80);
}else{
TEXT_SetBkColor(Status_bar,0x2079f4);
BUTTON_SetBitmapEx(Logo_window,BUTTON_BI_UNPRESSED,&bmlogo,20,80);
}
//////////////////////////////////////////////////////////////////////
//状态栏
color = get_color_NightMode(COLOR_BAR);
TopStatusWin[0] = hItem = WM_GetDialogItem(pMsg->hWin, ID_TOPstatus_Dogg1);
BUTTON_SetBkColor(hItem,BUTTON_BI_UNPRESSED,color);
WM_HideWindow(hItem);
TopStatusWin[1] = hItem = WM_GetDialogItem(pMsg->hWin, ID_TOPstatus_Dogg2);
BUTTON_SetBkColor(hItem,BUTTON_BI_UNPRESSED,color);
WM_HideWindow(hItem);
TopStatusWin[2] = hItem = WM_GetDialogItem(pMsg->hWin, ID_TOPstatus_Dogg3);
BUTTON_SetBkColor(hItem,BUTTON_BI_UNPRESSED,color);
WM_HideWindow(hItem);
TopStatusWin[3] = hItem =WM_GetDialogItem(pMsg->hWin, ID_TOPstatus_Decoy);
BUTTON_SetBkColor(hItem,BUTTON_BI_UNPRESSED,color);
WM_HideWindow(hItem);
TopStatusWin[4] = hItem =WM_GetDialogItem(pMsg->hWin, ID_TOPstatus_Battery);
BUTTON_SetBkColor(hItem,BUTTON_BI_UNPRESSED,color);
show_bat_icon();
// 时间
TopStatusWin[5] = hItem =WM_GetDialogItem(pMsg->hWin, ID_TOPstatus_TimerL);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_HCENTER);
sprintf(strbuf, "%02u:%02u", sound_info.current_time/60, sound_info.current_time%60);
TEXT_SetText(hItem,strbuf);
// 时间
TopStatusWin[6] = hItem =WM_GetDialogItem(pMsg->hWin, ID_TOPstatus_TimerR);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_HCENTER);
sprintf(strbuf, "%d:%02d", min, sec);
TEXT_SetText(hItem,strbuf);
/////////////////////////////////////////////////////////////////////////
//3行dogg状态
/////////////////////////////////////////////////////////////////////////
ListItem_doggs = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_USER1);
WM_SetWindowPos(ListItem_doggs,0,STATUS_BAR_Y,240,(ActiveDoggsNumber*20));
LISTBOX_AddString(ListItem_doggs, "");
resize_spk_lits(ActiveDoggsNumber);
LISTBOX_SetFont(ListItem_doggs, GUI_FONT_20_1);
LISTBOX_SetSel(ListItem_doggs,0);
for(i=0;i<Doggs_Display_MAX;i++){
tmp = i*7;
type = dogg[i].doggtype;
doggsWin[i][0] = hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_DoggIconL1+tmp);
icon = get_doggTypeIcon(&dogg[i],0);
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,icon,0,0);
WM_SetWindowPos(hItem, 18, (DOGG1_Y+9) +i*20 - icon->YSize,icon->XSize,icon->YSize);
if(type==0xFF)WM_HideWindow(hItem);
doggsWin[i][1] = hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DoggFileName_L1+tmp);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_HCENTER);
TEXT_SetFont(hItem, GUI_FONT_10_1);
if(type==0xFF)WM_HideWindow(hItem);
doggsWin[i][2] = hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_Signal_L1+tmp);
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,&bmwifi1,0,0);
if(type==0xFF)WM_HideWindow(hItem);
doggsWin[i][3] = hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_BatLevel_L1+tmp);
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,get_icon_battery(dogg[i].status),0,0);
if(type==0xFF)WM_HideWindow(hItem);
doggsWin[i][4] = hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DoggIDl_L1+tmp);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_HCENTER);
TEXT_SetFont(hItem, GUI_FONT_10_1);
sprintf(strbuf, "%04X",dogg[i].ID);
TEXT_SetText(hItem, strbuf);
if(type==0xFF)WM_HideWindow(hItem);
doggsWin[i][5] = hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_Speaker_L1+tmp);
BUTTON_SetBitmapEx(hItem,BUTTON_BI_UNPRESSED,&bmlabar,0,0);
if(type==0xFF)WM_HideWindow(hItem);
doggsWin[i][6] = hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DoggVol_L1+tmp);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_HCENTER);
TEXT_SetFont(hItem, GUI_FONT_10_1);
sprintf(strbuf,"%d",dogg[i].main_volume);
TEXT_SetText(hItem,strbuf);
if(type==0xFF)WM_HideWindow(hItem);
}
//dogg选择三角
doggSelectIcon =hItem= WM_GetDialogItem(pMsg->hWin, ID_BUTTON_TRI_Right);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_LEFT);
TEXT_SetTextColor(hItem, GUI_BLACK);
TEXT_SetFont(hItem, &GUI_FontWingdings3_16);
WM_HideWindow(doggSelectIcon);
current_dogg = &dogg[speaker];
WM_SetWindowPos(doggSelectIcon,2, (STATUS_BAR_Y+1)+(speaker*20), 20, 19);
//改变颜色
set_icon_backcolor(speaker);
////////////////////////////////////////////////////////////////////////////////
//主菜单标题栏
MainTitle = WM_GetDialogItem(pMsg->hWin, ID_TEXT_TITLE);
WM_SetWindowPos(MainTitle,0, offset_status_bar_ypx, 240, titile_height);
TEXT_SetTextAlign(MainTitle, TEXT_CF_VCENTER | TEXT_CF_HCENTER);
TEXT_SetTextColor(MainTitle, get_color_NightMode(COLOR_TITLE_TEXT));
TEXT_SetBkColor(MainTitle,get_color_NightMode(COLOR_Title_BACK));
TEXT_SetFont(MainTitle, GUI_FONT_32S);
//主菜单
ListItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_USER0);
WM_SetWindowPos(ListItem, 0, offset_list_ypx, 240, 280-offset_list_ypx);
LISTBOX_AddString(ListItem, "");
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_TEXT_LIST));
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_SEL,get_color_NightMode(COLOR_TEXT_LIST));
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_TEXT_LIST));
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_DISABLED,get_color_NightMode(COLOR_ListItem_DISABLE));
LISTBOX_SetBkColor(ListItem,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_ListItem_UNSEL));
LISTBOX_SetBkColor(ListItem,LISTBOX_CI_SEL,get_color_NightMode(COLOR_ListItem_UNSEL));
LISTBOX_SetBkColor(ListItem,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_SELECTED));
LISTBOX_SetBkColor(ListItem,LISTBOX_CI_DISABLED,get_color_NightMode(COLOR_ListItem_UNSEL));
LISTBOX_SetSel(ListItem,0);
WM_HideWindow(ListItem);
//hot1/2/3/4
for(i=0;i<4;i++)
{
BtnHotkey[i]=hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_HOTKEY1+i);
BUTTON_SetFont(hItem, GUI_FONT_13B_1);
BUTTON_SetText(hItem,hotkey_string(main_coff.hotkey[i]));
BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED ,get_color_NightMode(COLOR_TITLE_TEXT));
BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED,get_color_NightMode(COLOR_Title_BACK));
}
////////////////////////////////////////////////////////////////////////////////
//窗口通用部分
for(i=0;i<3;i++){
TextWin[i] =hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0+i);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_LEFT);
WM_HideWindow(hItem);
}
for(i=0;i<8;i++)
{
BtnWin[i] = hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_USER0+i);
BUTTON_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_HCENTER);
BUTTON_SetFont(hItem, GUI_FONT_16_1);
WM_HideWindow(hItem);
}
//////////////////////////////////////////////
ScrollUpWin =hItem= WM_GetDialogItem(pMsg->hWin, ID_BUTTON_TRI_UP);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_LEFT);
TEXT_SetTextColor(hItem, get_color_NightMode(COLOR_TEXT_LIST));
TEXT_SetFont(hItem, &GUI_FontWingdings3_16);
WM_HideWindow(ScrollUpWin);
ScrollDownWin =hItem= WM_GetDialogItem(pMsg->hWin, ID_BUTTON_TRI_DOWN);
TEXT_SetTextAlign(hItem, TEXT_CF_VCENTER | TEXT_CF_LEFT);
TEXT_SetTextColor(hItem, get_color_NightMode(COLOR_TEXT_LIST));
TEXT_SetFont(hItem, &GUI_FontWingdings3_16);
WM_HideWindow(ScrollDownWin);
ScrollWin = WM_GetDialogItem(pMsg->hWin, ID_SCROLL_BRIGHT);
SCROLLBAR_SetValue(ScrollWin,brightness);
WM_HideWindow(ScrollWin);
WIN_SLIDER_BASS = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_SVOL);
SLIDER_SetRange(WIN_SLIDER_BASS,-BASS_TREBLE_MAX,BASS_TREBLE_MAX);
SLIDER_SetNumTicks(WIN_SLIDER_BASS,(BASS_TREBLE_MAX<<1) +1);
WM_HideWindow(WIN_SLIDER_BASS);
WIN_SLIDER_TREBLE = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_TVOL);
SLIDER_SetRange(WIN_SLIDER_TREBLE,-BASS_TREBLE_MAX,BASS_TREBLE_MAX);
SLIDER_SetNumTicks(WIN_SLIDER_TREBLE,(BASS_TREBLE_MAX<<1) +1);
WM_HideWindow(WIN_SLIDER_TREBLE);
ProgWin = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS);
PROGBAR_SetValue(ProgWin, 0);
WM_HideWindow(ProgWin);
EditWin1 = WM_GetDialogItem(pMsg->hWin, ID_EDITBOX_USER0);
EDIT_SetTextAlign(EditWin1,TEXT_CF_VCENTER | TEXT_CF_LEFT);
EDIT_SetFont(EditWin1,GUI_FONT_16B_1);
//EDIT_SetTextColor(EditWin1,EDIT_CI_ENABLED,get_color_NightMode(COLOR_TEXT_LIST));
//EDIT_SetBkColor(EditWin1,EDIT_CI_ENABLED,get_color_NightMode(COLOR_EditBox_Back));
//EDIT_EnableBlink(EditWin1, 300, 1);//非常慢
WM_HideWindow(EditWin1);
/////////////////////////////////////
ListItem2 = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_USER2);
LISTBOX_AddString(ListItem2, "");
LISTBOX_SetTextAlign(ListItem2,GUI_TA_HCENTER);
LISTBOX_SetFont(ListItem2, GUI_FONT_24K);
for(i=LISTBOX_CI_UNSEL;i<=LISTBOX_CI_DISABLED;i++){
LISTBOX_SetTextColor(ListItem2,i,get_color_NightMode(COLOR_TEXT_LIST));
}
LISTBOX_SetBkColor(ListItem2,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_ListItem_UNSEL));
LISTBOX_SetBkColor(ListItem2,LISTBOX_CI_DISABLED,get_color_NightMode(COLOR_ListItem_BACK));
LISTBOX_SetBkColor(ListItem2,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_SELECTED));
LISTBOX_SetSel(ListItem2,0);
WM_HideWindow(ListItem2);
////////expert Hunt
ListItem3 = hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_USER3);
LISTBOX_AddString(ListItem3, "");
LISTBOX_SetTextAlign(ListItem3,GUI_TA_HCENTER);
LISTBOX_SetFont(ListItem3, GUI_FONT_20_1);
for(i=LISTBOX_CI_UNSEL;i<=LISTBOX_CI_DISABLED;i++)
{
LISTBOX_SetTextColor(ListItem3,i,get_color_NightMode(COLOR_TEXT_LIST));
}
LISTBOX_SetBkColor(ListItem3,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_ListItem_UNSEL));
LISTBOX_SetBkColor(ListItem3,LISTBOX_CI_DISABLED,get_color_NightMode(COLOR_ListItem_BACK));
LISTBOX_SetBkColor(ListItem3,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_SELECTED));
LISTBOX_SetSel(ListItem3,0);
WM_HideWindow(ListItem3);
hItem =Btnexp[0] = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_EXPH_Left);
BUTTON_SetFont(hItem, GUI_FONT_16B_1);
WM_HideWindow(hItem);
hItem =Btnexp[1] = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_EXPH_Mid);
BUTTON_SetFont(hItem, GUI_FONT_16B_1);
WM_HideWindow(hItem);
hItem =Btnexp[2] = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_EXPH_Right);
BUTTON_SetFont(hItem, GUI_FONT_16B_1);
WM_HideWindow(hItem);
listExperts = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_USER4);
LISTBOX_AddString(listExperts, "");
WM_HideWindow(listExperts);
listFavorites = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_USER5);
LISTBOX_AddString(listFavorites, "");
WM_HideWindow(listFavorites);
frame_created=1;
break;
case WM_NOTIFY_PARENT:
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
* Create keyboard
**********************************************************************/
WM_HWIN CreateKeyboard(void)
{
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogKeypad, GUI_COUNTOF(_aDialogKeypad), _cbDialogKeypad, WM_HBKWIN, 0, 0);
return hWin;
}
/*********************************************************************
* CreateWindow,主窗口
**********************************************************************/
WM_HWIN CreateWindow(void)
{
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
/*********************************************************************
* _FRM_FirstPage,开机画面
**********************************************************************/
WM_HWIN CreateFRM0(void)
{
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_FRMCreate, GUI_COUNTOF(_FRMCreate), _FRM_FirstPage, WM_HBKWIN, 0, 0);
return hWin;
}
void ListItem_SetItumTo(u8 size_list)
{
u8 tmp =LISTBOX_GetNumItems(ListItem);
while(tmp != size_list)
{
if(tmp > size_list)
{
LISTBOX_DeleteItem(ListItem,--tmp);
}
else
{
LISTBOX_AddString(ListItem, "");
tmp++;
}
}
}
void ListItem_clear_item(void)
{
u8 k;
WM_SetFocus(ListItem);
for(k=0;k<DISPLAY_LINE;k++)LISTBOX_SetString(ListItem, "",k);
ListItem_SetItumTo(0);
scroll_pos = 0;
WM_HideWindow(ScrollUpWin);
WM_HideWindow(ScrollDownWin);
}
void ListItem2_popup(u8 size_list){
u8 tmp;
WM_SetFocus(ListItem2);
LISTBOX_SetFont(ListItem2,GUI_FONT_24K);
pFnt = (const GUI_FONT *)LISTBOX_GetFont(ListItem2);
tmp = pFnt->YSize *size_list;
WM_SetWindowPos(ListItem2, 0, 280-tmp, 240, tmp);
tmp =LISTBOX_GetNumItems(ListItem2);
while(tmp != size_list)
{
if(tmp > size_list)
{
LISTBOX_DeleteItem(ListItem2,--tmp);
}
else
{
LISTBOX_AddString(ListItem2, "");
tmp++;
}
}
LISTBOX_SetBkColor(ListItem2,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_ListItem2_UNSEL));
LISTBOX_SetBkColor(ListItem2,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_SELECTED));
LISTBOX_SetTextColor(ListItem2,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_TEXT_LIST));
LISTBOX_SetTextColor(ListItem2,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_TEXT_LIST));
WM_ShowWindow(ListItem2);
list2_funtion=1;
}
void set_icon_backcolor(u8 sp)
{
u8 j;
u32 color;
LISTBOX_SetBkColor(ListItem_doggs,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_ListItem1_UNSEL));
LISTBOX_SetBkColor(ListItem_doggs,LISTBOX_CI_SEL,get_color_NightMode(COLOR_ListItem1_SELECTED));
LISTBOX_SetBkColor(ListItem_doggs,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem1_SELECTED));
for(j=0;j<Doggs_Display_MAX;j++)
{
if(j == sp)
color = get_color_NightMode(COLOR_ListItem1_SELECTED);
else
color = get_color_NightMode(COLOR_ListItem1_UNSEL);
BUTTON_SetBkColor(doggsWin[j][0],BUTTON_BI_UNPRESSED,color);
BUTTON_SetBkColor(doggsWin[j][2],BUTTON_BI_UNPRESSED,color);
BUTTON_SetBkColor(doggsWin[j][3],BUTTON_BI_UNPRESSED,color);
BUTTON_SetBkColor(doggsWin[j][5],BUTTON_BI_UNPRESSED,color);
}
}
u8 flag_1s=0;
u8 flag_1sB=0;
u8 timer_count_start=0;
u8 uart2_tx_buffer[Uart2TxNumByte];
volatile u8 uart2_tx_out=0;
volatile u8 uart2_tx_in=0;
//UART2 输出
u8 uart2_tx_output(u8* pBuffer,u8 NumByte)
{
u8 sum;
u8 next;
sum = 0;
while(1)
{
next=uart2_tx_in+1;
if(next >= Uart2TxNumByte)next =0;
if(next != uart2_tx_out)
{
uart2_tx_buffer[uart2_tx_in]= *pBuffer;
uart2_tx_in = next;
sum += *pBuffer;
pBuffer++;
if(--NumByte==0)break;
}
}
return sum;
}
vu8 flag_ack;
void sendtx(u16 id, u8 * txbuf,u8 attempts,u8 ack)
{
u8 nk;
u16* pb;
static u8 txcount,count;
u8 tx_chksum,sum;
u8 header[5]={0x55,0x7e,REMOTE_DEFAULT,0x00,0x00};
pb = (u16 *) & header[3];
*pb=id;
txcount = (txcount+1) & 0x0f;
count = attempts;
START:
if(attempts)
{
uart2_tx_output(&txcount,1);//用于判别重复命令
}
tx_chksum=0;
sum = uart2_tx_output(header,5);
tx_chksum -= sum;
nk=(txbuf[BUFFER_LENGTH] & 0x7f)+2;
sum = uart2_tx_output(txbuf,nk);
tx_chksum -= sum;
uart2_tx_output(&tx_chksum,1);
while(RF915_AUX==0 || flag_transmitting)polling();
flag_ack = 0xff;
USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
if(count)
{
delay_ms = AckTime;
while(delay_ms)
{
polling();
if(flag_ack == ack)return;
if(flag_ack != 0xff && ack == UART_COMMAND_ACK)return;
}
count--;
goto START;
}
}
vu8 countB=0;
void TIM2_IRQHandler(void)
{
static u8 count;
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM2,TIM_IT_Update); //TIM_FLAG_Update
if(flag_power ==1 && LCD_brightness)
{
LCD_brightness--;
set_brightness(LCD_brightness);
if(LCD_brightness ==0){
BackLight_OFF();
}
}
if(++count >= 20)
{
count = 0;
flag_1s=1;
}
if(sound_info.state == SOUND_PLAYING)
{
if(++countB >= 20)
{
countB = 0;
flag_1sB=1;
}
}
}
}
u16 Get_val(u8 ch)
{
u16 DataValue;
/*ADC1 regular channel14 configuration */
ADC_RegularChannelConfig(ADC1, ch, 1, ADC_SampleTime_239Cycles5);
/* Start ADC1 Software Conversion */
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
/* Test if the ADC1 EOC flag is set or not */
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC));
//FlagStatus Status;
//Status = ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC);
//while(!Status);---->
/*Returns the ADC1 Master data value of the last converted channel*/
DataValue = ADC_GetConversionValue(ADC1);
return DataValue;
}
u16 ADC_Get_aveg(u8 ch,u8 n)
{
u32 ad_sum = 0;
u8 i;
for(i=0;i<n;i++)
{
ad_sum += Get_val(ch);
//Delay_Mus(5000);
}
return (ad_sum / n);
}
vu8 key_code;
u8 System_GetKeys(void)
{
u16 tmp=0,tmp1;
u8 key;
tmp1 = GPIO_ReadInputData(GPIOA);
if(tmp1 & GPIO_Pin_8)tmp |= 1;
if(tmp1 & GPIO_Pin_9)tmp |= 2;
if(tmp1 & GPIO_Pin_10) tmp |= 4;
tmp1 = GPIO_ReadInputData(GPIOB);
if(tmp1 & GPIO_Pin_3) tmp |= 0x0010;//enter
if(tmp1 & GPIO_Pin_8)tmp |= 0x0020;
if(tmp1 & GPIO_Pin_9)tmp |= 0x0040;
tmp |= (GPIO_ReadInputData(GPIOC) & 0x0f80);
tmp ^= 0x0ff7;
switch(tmp)
{
case 0:
key = KEY_NONE;
break;
case GPIO_Pin_0:
key = KEY_DOWN;
break;
case GPIO_Pin_1:
key = KEY_MENU;
break;
case GPIO_Pin_2:
key = KEY_BACK;
break;
case GPIO_Pin_4:
key = KEY_ENTER;
break;
case GPIO_Pin_5:
key = KEY_HOT4;
break;
case GPIO_Pin_6:
key = KEY_HOT3;
break;
case GPIO_Pin_7:
key = KEY_LEFT;
break;
case GPIO_Pin_8:
key = KEY_RIGHT;
break;
case GPIO_Pin_9:
key = KEY_UP;
break;
case GPIO_Pin_10:
key = KEY_HOT2;
break;
case GPIO_Pin_11:
key = KEY_HOT1;
break;
default:
key = KEY_ERROR;
break;
}
return key;
}
uint8_t key_define(uint8_t key, uint8_t keymode)
{
uint8_t k = KEY_NONE;
switch(keymode)
{
default:
break;
case KEY_EVENT_DOWN:
switch(key)
{
case KEY_BACK:
case KEY_MENU:
case KEY_UP:
case KEY_DOWN:
case KEY_LEFT:
case KEY_RIGHT:
k=key;
break;
}
break;
case KEY_EVENT_SHOT:
if(key >= KEY_ENTER && key <= KEY_HOT4)k=key;
break;
case KEY_EVENT_POWERDOWN:
if(key == KEY_ENTER)k= KEY_POWER_OFF;
break;
case KEY_EVENT_HOTKEY:
switch(key)
{
case KEY_HOT1:
k=KEY_HOT1_SETUP;
break;
case KEY_HOT2:
k=KEY_HOT2_SETUP;
break;
case KEY_HOT3:
k=KEY_HOT3_SETUP;
break;
case KEY_HOT4:
k=KEY_HOT4_SETUP;
break;
}
break;
case KEY_EVENT_REPEAT:
if(key == KEY_LEFT || key == KEY_RIGHT)k= key;
break;
}
if(k != KEY_NONE)key_code = k;
return k;
}
u8 key_clik;
u8 key_repeat_count;
void key_scan_task(void)
{
uint8_t key_current_detect;//当前按键
static uint8_t key_last_detect;//上次检测
static uint8_t key_last_clik;
static uint16_t Time_clik; //时间计时
key_current_detect = System_GetKeys();
if(key_current_detect != key_last_detect)//去抖动
{
key_last_detect = key_current_detect;
return;
}
//------------------------
if(Time_clik <60000)Time_clik++;
switch(key_clik)
{
case 0://无按键
if(key_current_detect != KEY_NONE)//按下
{
key_clik=1;
Time_clik=0;
key_repeat_count = 0;
key_last_clik=key_current_detect;
}
break;
case 1://已经按下
if(key_current_detect==KEY_NONE)
{
if(Time_clik < KEY_SHOT_DELAY)
{
key_define(key_last_clik,KEY_EVENT_SHOT);
}
key_clik =0;
return;
}
else if(Time_clik == KEY_MIN_DELAY)
{
key_define(key_current_detect,KEY_EVENT_DOWN);
}
if(Time_clik==TIME_FIRST_REPEAT)
{
if(key_define(key_current_detect,KEY_EVENT_REPEAT) != KEY_NONE)
{
Time_clik = TIME_FIRST_REPEAT-TIME_REPEAT;
if(key_repeat_count < 0xff) key_repeat_count ++;
}
}
if(Time_clik==KEYTIME_HOTKEY)
{
key_define(key_current_detect,KEY_EVENT_HOTKEY);
}
else if(Time_clik==KEYTIME_POWERDOWN)
{
key_define(key_current_detect,KEY_EVENT_POWERDOWN);
}
break;
default: //等待弹起
if(key_current_detect==KEY_NONE) key_clik =0;
break;
}
}
static u8 tmp_adj[6];//用于设置页面临时保存数据
#ifdef SAVE_DELAY
u8 save_delay;
#define saveCoff_in_Flash() {save_delay = SAVE_DELAY;}
#else
#define saveCoff_in_Flash() saveCoff_in_stm32()
#endif
#include "stm32f10x_flash.h"
void simple_write_flash(uint32_t WriteAddress, uint8_t* data, uint32_t num)
{
u32 i,j = 0;
u16 temp = 0;
WriteAddress += FLASH_DATA_STARTADDR;
FLASH_Unlock(); //解锁flash
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
if(num%2)
{
j=num-1;
}
else
{
j=num;
}
for(i=0; i<j; i++)
{
if(!(i%2))
{
temp = (uint16_t)data[i];
}
else
{
temp |= (uint16_t)(data[i]<<8);
FLASH_ProgramHalfWord(WriteAddress+(i-1), temp);//写入数据
}
}
if(i<num)
{
temp = (uint16_t)data[i];
FLASH_ProgramHalfWord(WriteAddress+i, temp);//写入数据
}
FLASH_Lock();//上锁写保护
}
void saveCoff_in_stm32(void)
{
u16 count;
u32 address;
u16 * writeData;
address = MCU_ParamFlashAdd;
while(address < (u32)(MCU_ParamFlashAdd+STM32_SECTOR_SIZE-CoffSizeInFlash*2))
{
if(*(__IO u32*)address == 0xffffffff)break;
address += CoffSizeInFlash;
}
FLASH_Unlock(); //解锁写保护
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
if(address >= (u32)(MCU_ParamFlashAdd+STM32_SECTOR_SIZE-CoffSizeInFlash))
{
address = MCU_ParamFlashAdd;
FLASH_ErasePage(MCU_ParamFlashAdd);//擦除这个扇区
}
writeData=(u16 *)&main_coff;
count=0;
while(count < sizeof(main_coff))
{
FLASH_ProgramHalfWord(address,*writeData);
count+=2;
address+=2;
writeData++;
}
FLASH_Lock();//上锁写保护
}
u16 flag_spiflash_write=0;
void save_RegistDoggs_in_flash(void)
{
u16 count;
u32 address;
u16 * writeData;
address = DOGG_Attribute_OFFST;
while(address <= (u32)(DOGG_Attribute_OFFST+STM32_SECTOR_SIZE-AttributeInFlash))
{
if(*(__IO u32*)address == 0xffffffff)break;
address += AttributeInFlash;
}
FLASH_Unlock(); //解锁写保护
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
if(address > (u32)(DOGG_Attribute_OFFST+STM32_SECTOR_SIZE-AttributeInFlash))
{
address = DOGG_Attribute_OFFST;
FLASH_ErasePage(DOGG_Attribute_OFFST);//擦除这个扇区
}
writeData=(u16 *)registed_dogg;
count=0;
while(count < sizeof(registed_dogg))
{
FLASH_ProgramHalfWord(address,*writeData);
count+=2;
address+=2;
writeData++;
}
FLASH_Lock();//上锁写保护
}
void reset_dogg(u8 spk)
{
DOGG_Type * p;
p = &dogg[spk];
p->doggtype =0xff;
p->setting = DEFAULT_SETTING;
p->status = 0;
p->time_connected=0;
p->main_volume=DEFAULT_VOL;
p->TweeterVol = 0;
p->SubwooferVol = 0;
p->ID=0xffff;
p->name[0]=0;
p->FwVerssion[0]=0;
p->MemState = 0;
p->reg_index=0xff;
p->tree.sizeTree=0xffff;
p->hunt.sizeTree=0xffff;
p->favorite.sizeTree=0xffff;
}
void restore_set_default(void)
{
u8 i;
u32 address;
//读取指定地址的数据
address = MCU_ParamFlashAdd;
while(address <= (u32)(MCU_ParamFlashAdd+STM32_SECTOR_SIZE-CoffSizeInFlash*2))
{
if(*(__IO u32*)(address+CoffSizeInFlash) == 0xffffffff)break;
address += CoffSizeInFlash;
}
memcpy((u8 *)&main_coff,(u8 *)address,sizeof(main_coff));
if(main_coff.night_mode>1)main_coff.night_mode=0;
if(main_coff.font_size>2)main_coff.font_size=2;
if(main_coff.hotkey[0]>=HotKey_ERROR) main_coff.hotkey[0]=HotKey_NightMode;
if(main_coff.hotkey[1]>=HotKey_ERROR) main_coff.hotkey[1]=HotKey_AllOff;
if(main_coff.hotkey[2]>=HotKey_ERROR) main_coff.hotkey[2]=HotKey_SettingsMenu;
if(main_coff.hotkey[3]>=HotKey_ERROR) main_coff.hotkey[3]=HotKey_MainMenu;
//从flash恢复注册的狗资料到ram
address = DOGG_Attribute_OFFST;
while(address <= (u32)(DOGG_Attribute_OFFST+STM32_SECTOR_SIZE-AttributeInFlash*2))
{
if(*(__IO u32*)(address+AttributeInFlash) == 0xffffffff)break;
address += AttributeInFlash;
}
memcpy((u8 *)registed_dogg,(u8 *)address,sizeof(registed_dogg));
for(i=0;i<Doggs_List_MAX;i++)
{
reset_dogg(i);
}
decoy_link=0;
decoy_speed=0;
timer_enable=0;
brightness=75;
}
void display_doggName2buffer(char * p,u16 id)
{
u8 k;
for (k=0;k < Doggs_REG_MAX;k++)
{
if(registed_dogg[k].ID == id && registed_dogg[k].name[0]!=0xff && registed_dogg[k].name[0]!=0)
{
sprintf(p,"\"%s\"", registed_dogg[k].name);
return;
}
}
for (k=0;k < Doggs_List_MAX;k++)
{
if(dogg[k].ID == id && dogg[k].name[0]!=0xff && dogg[k].name[0]!=0)
{
sprintf(p,"\"%s\"", dogg[k].name);
return;
}
}
sprintf(p,"\"%04X\"", id);
}
//*********************************************************
//检查flash的tree占用空间
//*********************************************************
u16 get_tree_size(u32 buff_base)
{
#ifdef USE_SPI_FLASH
u8 *p;
u16 count_size = 2;
u8 k;
char buffer_ser[33];
u32 add = buff_base + FLASH_DATA_STARTADDR;
while(count_size < 10000){
SPI_FLASH_BufferRead(buffer_ser, add, 33);
p = buffer_ser;
for(k=0;k < 32;k++){
if((*p == 'N' || *p =='C')&& *(p+1)==0x17)return count_size; //0x17目录树结束
count_size++;
}
add += 32;
}
#else
__IO u8 *p;
u16 count_size = 2;
p = (__IO u8 *)(buff_base+FLASH_DATA_STARTADDR);
while(count_size < 10000){
if((*p == 'N' || *p =='C')&& *(p+1)==0x17)return count_size; //0x17目录树结束
p++;
count_size++;
}
#endif
return 0xffff;
}
//*********************************************************
//获取文件夹内列表数
//*********************************************************
u8 get_node_size(u32 buff_base,u16 base_node)
{
u8 count_size = 0;
#ifdef USE_SPI_FLASH
u8 k,tmp;
char buffer_ser[Max_stringlen];
u32 add = buff_base+base_node+FLASH_DATA_STARTADDR; //指向开始位置
count_size = 0;
SPI_FLASH_BufferRead(buffer_ser, add, Max_stringlen);//读取一段
k = 4;//偏移4,指向字符串开始位置
while(1){
//查找字符串结尾字符
if(buffer_ser[k] != 0x00){
if(++k==Max_stringlen){
k = 0;
SPI_FLASH_BufferRead(buffer_ser, add, Max_stringlen);
}
add++;
}
//偏移2字节,检查是否最后一个
tmp = 2;
if(tmp--){
if(++k==Max_stringlen){
k = 0;
SPI_FLASH_BufferRead(buffer_ser, add, Max_stringlen);
}
add++;
}
count_size++;
tmp = buffer_ser[k];
if(tmp == 0x0A || tmp == 0x17)return count_size; //0x0A文件夹结束,0x17目录树结束
//偏移1,指向字符串开始地址
if(++k==Max_stringlen){
k = 0;
SPI_FLASH_BufferRead(buffer_ser, add, Max_stringlen);
}
add++;
}
#else
char *p= (char *)(buff_base+base_node+FLASH_DATA_STARTADDR);
p += 4;
while(1){
p += strlen(p);
count_size++;
p += 2;
if(*p == 0x0A || *p == 0x17)return count_size; //0x0A文件夹结束,0x17目录树结束
p++;
}
#endif
}
//*********************************************************
//获取列表字符串位置
//*********************************************************
u16 get_nd_item_dir(u32 buff_base,u16 base_node,u8 index)
{
u8 size;
vu8 item;
vu16 idx_tree;
char * p;
p = (char *)(buff_base+base_node+FLASH_DATA_STARTADDR);
p+= 4;//跳过开始4个字节索引
idx_tree = base_node+4;
if(index==0)return idx_tree;
///////
item =1;
while(item <= index)
{
size = strlen(p)+3;
idx_tree += size;
p += (size-1);
if(*p ==0x0A||*p==0x17)return 0;
if(item == index)return idx_tree;
p++;
item++;
}
return 0;
}
//*********************************************************
//获取选择的文件名和类型
//*********************************************************
u8 get_node_item(u32 buff_base,u16 base_node,u8 index,char** name, u8* type)
{
u8 k;
char * p = (char*)(buff_base + base_node + FLASH_DATA_STARTADDR);
p+= 4;//跳过开始4个字节索引
if(index == 0)
{
*name = p;
}
for(k=1; k <= index; k++)
{
p += strlen(p);
p += 2;//跳过字符串结束符和类型标志
if((*p ==0x0A)||(*p ==0x17))//结束标志
{
name = NULL;
return 0;
}
p++;//移到 字符串开始位置
if(k == index)
{
*name = p;
}
}
//类型
if(*(p-1)=='N')
{
*type = Type_Folder;//folder
}
else
{
*type = Type_file;//file
}
return 1;
}
//找出名称为dir的项目在buffer_ser位置偏移量
u16 idx_open_dir(char* buffer_ser,char* dir)
{
u16 *ptr_int;
u16 idx_tree=2;
buffer_ser += FLASH_DATA_STARTADDR;
ptr_int=(u16* )buffer_ser;
if(!strcmp(&buffer_ser[idx_tree],dir))
{
return idx_tree;
}
//search in child nodes
idx_tree=(*ptr_int)+4;
while(1)
{
if(!strcmp(&buffer_ser[idx_tree],dir))
{
return idx_tree;
}
else
{ //next child
idx_tree+=strlen(&buffer_ser[idx_tree])+3;
if(buffer_ser[idx_tree-1]==0x0A)//fin de nodo
{
idx_tree+=4;
}
if(buffer_ser[idx_tree-1]==0x17)//fin de arbol
return 0xffff;
}
}
}
//*********************************************************
//获取文件夹列表的位置
//返回: 地址偏移量
//*********************************************************
u16 get_NodeBase1(u32 add_start,u16 node)
{
u8 size ;
u16 index;
u16 node1;
char * p;
u8 type ;
p = (char *)(add_start + node + FLASH_DATA_STARTADDR);
index = node;//跳过前面部分, 从这个位置开始
while(1){
while(1){
size = strlen(p)+3;
p += size;
index += size;
if(index > 9999)return 0xff;
type = *(p-1);
if(type == 0x0a)
break;
else if(type==0x17)
return 0xff;
}
/////////////////
p+=2;
node1 = *(u16*)p;
if(node1 == node)return index;
p+=2;
index += 4;
if(index > 9999)return 0xff;
}
}
void send_FileIndex_cmd(u16 id,u8 cmd,u8 deepth,u8 fileIndex)
{
u8 k;
u8 * p;
u8 TxBuf[Max_depth+6];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|cmd;
p = &TxBuf[BUFFER_LENGTH];
*p++ = deepth+1;
for(k=0;k < deepth;k++)
{
*p++= current_path[k].index;
}
*p = fileIndex;
while(flag_transmitting)
{
polling();
}
sendtx(id,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
void send_FilePath_cmd(u16 id,u8 cmd,char * path)
{
u8 * p;
char TxBuf[Max_depth+6];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|cmd;
p = &TxBuf[BUFFER_LENGTH];
*p++ = strlen(path)+2;
strcpy(p,path);
while(flag_transmitting)
{
polling();
}
sendtx(id,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
void send_FileDirNode_cmd(u16 id,u8 cmd,u16 dir)
{
u8 TxBuf[Max_depth+6];
dir_serial_tree.int_data=dir;
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|cmd;
TxBuf[BUFFER_LENGTH]= 3;
TxBuf[BUFFER_PARAM1] = 2;
TxBuf[BUFFER_PARAM1+1] = dir_serial_tree.bytes[0];
TxBuf[BUFFER_PARAM1+2] = dir_serial_tree.bytes[1];
sendtx(id,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
void send_File_Expert(u16 id,u8 cmd,char *name,u8 option_in)
{
u8 k,len;
u8 TxBuf[40];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|cmd;
TxBuf[BUFFER_PARAM1] = option_in;
len= strlen(name)+1;
TxBuf[BUFFER_LENGTH]= len+1;
strcpy((char *)&TxBuf[BUFFER_PARAM1+k+1],name);
sendtx(id,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
vu8 RXsync_block_size;
void send_sync_cmd(u16 id,u8 step, u8 block)
{
u8 TxBuf[6];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|UART_COMMAND_Sync;
TxBuf[BUFFER_LENGTH]= 2;
TxBuf[BUFFER_PARAM1]= step;
TxBuf[BUFFER_PARAM1+1]= block;
sendtx(id,TxBuf,TRANSFER_ONCE,UART_COMMAND_Sync);
}
void Remote_create_ExpH(u16 id,char* name,u16* dir,u8 size)
{
u8 k,len;
u8 TxBuf[200];
char intsBuff[30];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|UART_COMMAND_Sync;
len = strlen(name)+1;
TxBuf[BUFFER_PARAM1]=3;
for(k=0;k<len;k++)
{
TxBuf[BUFFER_PARAM1+k+1] = name[k];
}
TxBuf[BUFFER_LENGTH]= size*2+len+1;
sprintf(intsBuff,"size out(%u)",TxBuf[BUFFER_LENGTH]);
TEXT_SetText(MainTitle,intsBuff);
for(k=0;k<(size*2);k+=2)
{
dir_serial_tree.int_data=dir[k/2];
TxBuf[BUFFER_PARAM1+k+len+1] = dir_serial_tree.bytes[0];
TxBuf[BUFFER_PARAM1+k+2+len] = dir_serial_tree.bytes[1];
}
sendtx(id,TxBuf,TRANSFER_WaitAck,UART_COMMAND_Sync);
}
void read_register(u16 id, u8 add,u8 ack)
{
u8 TxBuf[BUFFER_PARAM1+1];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|UART_COMMAND_READ;
TxBuf[BUFFER_LENGTH]=1;//1个参数
TxBuf[BUFFER_PARAM1]=add;
sendtx(id,TxBuf,ack,UART_COMMAND_READ);
}
void write_register(u16 id,u8 add, u8 da)
{
u8 TxBuf[BUFFER_PARAM1+2];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|UART_COMMAND_WRITE;
TxBuf[BUFFER_LENGTH]=2;//2个参数
TxBuf[BUFFER_PARAM1]=add;
TxBuf[BUFFER_PARAM1+1]=da;
sendtx(id,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
void write_doggName(u16 id, char * name)
{
u8 TxBuf[BUFFER_PARAM1+2];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|UART_COMMAND_WRITE;
TxBuf[BUFFER_LENGTH]=strlen(name)+2;
TxBuf[BUFFER_PARAM1]=8;
strcpy((void *)&TxBuf[BUFFER_PARAM1+1],name);
sendtx(id,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
void cut_filename_extension(char* name )
{
u8 size;
char *p = name;
size = strlen(name);
p += size;
while(size--){
if(*p == '.'){
*p=NULL;
break;
}
p--;
}
}
void quit_extension(char* in_str , char* out_str, u8 size_in)
{
char *p_new;
u16 idx_ext;
if((p_new = strchr(in_str,'.'))!=NULL)
{
idx_ext=p_new-in_str;
if(idx_ext>(size_in-1))idx_ext=size_in-1;
strncpy(out_str,in_str,idx_ext);
out_str[idx_ext]=0;
}
else
{
strcpy(out_str,in_str);
}
}
//列出一个文件夹global_node的文件(夹)列表
u8 list_draw_childs(u32 buff_base,u16 base_node)
{
u16 index;
u8 list,size;
__IO char *p;
char aux_str[50];
ListItem_clear_item();
if(base_node == 0xffff)return 0xff;
scroll_pos=0;
p = (__IO char *)(buff_base + base_node + FLASH_DATA_STARTADDR);
p += 4;//跳过开始4个字节索引
index = base_node+4;
list = 0;
while(1){
strcpy(aux_str,(void *)p);
size = strlen(aux_str);
p += (size+1);
list_attr[list].type =*p;
list_attr[list].node = index;
if(*p=='C'){//file
cut_filename_extension(aux_str);
}
if(folderdeep == 0 && (!btn_horz) && *p=='N'
&& (strcmp(aux_str,"Expert Hunts")==0 ||strcmp(aux_str,"Hunts")==0))//过滤这个文件夹
{
flag_hunt_index = list;
}else{
LISTBOX_AddString(ListItem,aux_str);
list++;
}
p++;
if((*p ==0x0A)||(*p ==0x17))break;
p++;
index += (size+3);
}
LISTBOX_UpdateScrollers(ListItem);
return list;
}
void upgrade_favorites(void)
{
u8 tmp,count;
char * p;
tmp =LISTBOX_GetNumItems(listFavorites);
while(tmp>0)
{
LISTBOX_DeleteItem(listFavorites,tmp-1);
tmp--;
}
p=(char *)((current_dogg->favorite.DirTree) + FLASH_DATA_STARTADDR);
tmp=*p;
if((!tmp)||(tmp==0xff))return;
if(tmp!=0xff)
{
p+=2;
for(count = 0; count < tmp ; count++)
{
LISTBOX_AddString(listFavorites,"");
p+=40;
}
}
}
u8 draw_favorites(void)
{
u8 list,tmp;
u16 node;
u32 add;
char intsBuff[Max_stringlen+1];
intsBuff[Max_stringlen]=0;
#if 1
tmp =LISTBOX_GetNumItems(listFavorites);
while(tmp)
{
LISTBOX_DeleteItem(listFavorites,--tmp);
}
#endif
add = current_dogg->favorite.DirTree + FLASH_DATA_STARTADDR;
list = 0;
node = 0;
while(1)
{
#ifdef USE_SPI_FLASH
SPI_FLASH_BufferRead((u8 *)intsBuff,add,Max_stringlen);
#else
memcpy((void *)intsBuff,(void *)add,Max_stringlen);
#endif
if(*(u8*)intsBuff == 0 || *(u8*)intsBuff == 0xff)break;
LISTBOX_AddString(listFavorites,intsBuff);
cut_filename_extension(intsBuff);
LISTBOX_AddString(ListItem,intsBuff);
list_attr[list].type ='C';
list_attr[list].node = node;
list++;
tmp = (strlen(intsBuff)+1);
node += tmp;
add += tmp;
if(node >= current_dogg->favorite.sizeTree || node >= FAVORITE_SIZE)break;
}
return list;
}
u8 draw_expert_list(void)
{
u8 tmp,count;
u16 size;
u32 add;
char intsBuff[EpertHuntName_MAX+1];
intsBuff[EpertHuntName_MAX]=0;
#if 1
tmp = LISTBOX_GetNumItems(listExperts);
while(tmp)
{
LISTBOX_DeleteItem(listExperts,--tmp);
}
#endif
add = current_dogg->hunt.DirTree + FLASH_DATA_STARTADDR;
size = 0;
count = 0;
while(1)
{
#ifdef USE_SPI_FLASH
SPI_FLASH_BufferRead((u8 *)intsBuff,add,EpertHuntName_MAX);
#else
memcpy((void *)intsBuff,(void *)add,EpertHuntName_MAX);
#endif
if(*(u8*)intsBuff == 0 || *(u8*)intsBuff == 0xff)break;
LISTBOX_AddString(listExperts,intsBuff);
cut_filename_extension(intsBuff);
LISTBOX_AddString(ListItem,intsBuff);
list_attr[count].type ='C';
list_attr[count].node = size;
count++;
tmp = (strlen(intsBuff)+1);
add += tmp;
size += tmp;
if((size >= (current_dogg->hunt.sizeTree)) || (size >= EXPT_HUNTS_SIZE))break;
}
return count;
}
void SaveChangeFavorite(void)
{
char aux_str[Max_stringlen+1];
u16 count;
u8 tmp;
u8 size;
u32 add;
flash_erase_nbytes(current_dogg->favorite.DirTree,FAVORITE_SIZE);
tmp = LISTBOX_GetNumItems(listFavorites);
add = current_dogg->favorite.DirTree;
for(count = 0; count < tmp ; count++)
{
LISTBOX_GetItemText(listFavorites,count,aux_str,Max_stringlen);
size = strlen(aux_str)+1;
simple_write_flash(add, (u8*)aux_str,size);
add += size;
}
}
void upgrade_expert(void)
{
u16 count;
u8 tmp;
u32 add;
u8 size;
char aux_str[Max_stringlen+1];
//clear list
tmp =LISTBOX_GetNumItems(listExperts);
while(tmp>0)
{
LISTBOX_DeleteItem(listExperts,tmp-1);
tmp--;
}
if(get_tree_size(current_dogg->tree.DirTree)==0xffff)return;
flash_erase_nbytes(current_dogg->hunt.DirTree,EXPT_HUNTS_SIZE);
add = current_dogg->hunt.DirTree;
for(count = 0; count < tmp ; count++)
{
LISTBOX_GetItemText(listExperts,count,aux_str,Max_stringlen);
size = strlen(aux_str)+1;
simple_write_flash(add, (u8*)aux_str,size);
add +=size;
}
}
void list_play_file(void)
{
char intsBuff[Max_stringlen];
vu8 tmp,count,tmpb;
vu16 tmp16;
char intBuff[10];
//sprintf(intBuff, "%02u:%02u", sound_info.current_time/60, sound_info.current_time%60);
//TEXT_SetText(TopStatusWin[5],intBuff);
TEXT_SetText(TopStatusWin[5],"00:00");//左边时间
sound_info.current_time=0;
sound_info.duration_time=0;
if(((sub_expert_menu)||(menu_page==MENU_ExpertHunts))&&(!reading_mode_option))
{
if(sub_expert_menu)stop_out =1;
LISTBOX_SetString(ListItem2,"Stop",0);
}
else
{
LISTBOX_SetString(ListItem2,"Pause",0);
}
////////////////////
if(menu_page==MENU_ExpertHunts)
{
tmp = LISTBOX_GetSel(ListItem);
strcpy(intsBuff,(void *)(list_attr[tmp].node+current_dogg->hunt.DirTree+FLASH_DATA_STARTADDR));
send_File_Expert(current_dogg->ID,UART_COMMAND_PlayFile,intsBuff,PLAY_OPTION);
}
else if(menu_page==MENU_FavorriteSounds)//喜爱
{
tmp = LISTBOX_GetSel(ListItem);
strcpy(intsBuff,(void *)(list_attr[tmp].node+current_dogg->favorite.DirTree+FLASH_DATA_STARTADDR));
//?没有扩展名,查找原文件位置
tmpb= strlen(intsBuff);
strcpy(&intsBuff[tmpb],".mp3");
tmp16=idx_open_dir((char *)current_dogg->tree.DirTree,intsBuff);
if(tmp16==0xFFFF)//没找到
{
strcpy(&intsBuff[tmpb],".prm");
tmp16=idx_open_dir((char *)current_dogg->tree.DirTree,intsBuff);
if(tmp16==0xFFFF)//没找到,在hunt找
{
tmp = LISTBOX_GetSel(ListItem);
LISTBOX_GetItemText(ListItem,tmp,intsBuff,EpertHuntName_MAX);
intsBuff[EpertHuntName_MAX-1]=0;
send_File_Expert(current_dogg->ID,UART_COMMAND_PlayFile,intsBuff,PLAY_OPTION);
}
else
{
send_FileDirNode_cmd(current_dogg->ID,UART_COMMAND_PlayFile,tmp16);
}
}
else
{
send_FileDirNode_cmd(current_dogg->ID,UART_COMMAND_PlayFile,tmp16);
}
}
else //卡文件列表
{
tmp = LISTBOX_GetSel(ListItem);
if((!mode_EP_navigation)&&(sub_expert_menu))
{
tmp16 =tmp_expert[selected_itemexpert];
send_FileDirNode_cmd(current_dogg->ID,UART_COMMAND_PlayFile,tmp16);
}
else
{
current_play_node = current_path[folderdeep].node;
send_FileIndex_cmd(current_dogg->ID,UART_COMMAND_PlayIndex,folderdeep,tmp);
}
}
//显示文件名
if((!sub_expert_menu))//&&(menu_page!=MENU_ExpertHunts)
{
LISTBOX_GetItemText(ListItem,tmp,intsBuff,10);
tmp = id_to_spk(current_dogg->ID);
TEXT_SetText(doggsWin[tmp][1],intsBuff);
}
sound_info.state = SOUND_PLAYING;
timer_count_start=1;
}
void file_play_pause(void)
{
if(list2_funtion == 2)
{
LISTBOX_SetString(ListItem2,"Play",0);
write_register(current_dogg->ID,4,3);//pause
list2_funtion = 3;
if(((sub_expert_menu)||(menu_page==MENU_ExpertHunts))&&(!reading_mode_option))
{
sound_info.state = SOUND_STOPPED;
sound_info.current_time =0;
}
else
{
sound_info.state = SOUND_PAUSED;
}
}
else
{
timer_count_start=1;
LISTBOX_SetString(ListItem2,"Pause",0);
write_register(current_dogg->ID,4,2);//play
list2_funtion = 2;
sound_info.state = SOUND_PLAYING;
}
}
void folder_option_list(u8 funtion)
{
char intsBuff[Max_stringlen];
vu8 tmp,count,tmpb;
vu16 tmp16;
char *p;
u8 file_type;
u32 add;
u8 size;
switch(funtion)
{
default:
sound_info.state = SOUND_STOPPED;
sound_info.current_time =0;
break;
case 0://play
if(list2_funtion==1){
list_play_file();
list2_funtion = 2;
}else {
file_play_pause();
}
break;
case 2://add to favorite/ add to expert hunt / delete
if(menu_page==MENU_ExpertHunts)
{
if(reading_mode_option)
{
tmp = LISTBOX_GetSel(ListItem);
LISTBOX_GetItemText(ListItem,tmp,intsBuff,Max_stringlen);
intsBuff[Max_stringlen-1]=0;
LISTBOX_AddString(listFavorites,intsBuff);
SaveChangeFavorite();
Dialog_Now(&bmok,"Successful\nAdded to Favorites!");
}
else
{
LISTBOX_SetBkColor(ListItem,LISTBOX_CI_SEL,get_color_NightMode(COLOR_ListItem_SELECTED));
tmp = LISTBOX_GetSel(ListItem)-1;
LISTBOX_GetItemText(listExperts,tmp,intsBuff,EpertHuntName_MAX);
intsBuff[EpertHuntName_MAX-1]=0;
send_File_Expert(dogg[speaker].ID,UART_COMMAND_PlayFile,intsBuff,DELETE_OPTION);
count=LISTBOX_GetSel(ListItem)-1;
tmpb=LISTBOX_GetNumItems(listExperts)-1;
for(tmp=count;tmp<tmpb;tmp++)
{
LISTBOX_GetItemText(listExperts,tmp+1,intsBuff,EpertHuntName_MAX);
intsBuff[EpertHuntName_MAX-1]=0;
LISTBOX_SetString(listExperts,intsBuff,tmp);
}
LISTBOX_DeleteItem(listExperts,tmpb);
flash_erase_nbytes(current_dogg->hunt.DirTree,EXPT_HUNTS_SIZE);
tmp =LISTBOX_GetNumItems(listExperts);
add = current_dogg->hunt.DirTree;
for(count = 0; count < tmp ; count++)
{
LISTBOX_GetItemText(listExperts,count,intsBuff,EpertHuntName_MAX);
intsBuff[EpertHuntName_MAX-1]=0;
size=strlen(intsBuff)+1;
simple_write_flash(add, (u8*)intsBuff,size);
add += size;
}
WM_HideWindow(ListItem2);
list2_funtion=0;
ExpertHunts_page();
}
}
else if(sub_expert_menu)
{
WM_HideWindow(ListItem2);
list2_funtion=0;
if(!mode_EP_navigation)
{
if(tmp_expert_idx>(selected_itemexpert+1))
{
for(tmp=selected_itemexpert;tmp<(tmp_expert_idx-selected_itemexpert);tmp++)
{
tmp_expert[tmp]=tmp_expert[tmp+1];
LISTBOX_GetItemText(ListItem3,tmp+1,intsBuff,30);
intsBuff[29]=0;
LISTBOX_SetString(ListItem3,intsBuff,tmp);
}
}
if(selected_itemexpert)selected_itemexpert--;
if(tmp_expert_idx)LISTBOX_SetSel(ListItem3,selected_itemexpert);
tmp_expert_idx--;
if(!tmp_expert_idx)LISTBOX_SetBkColor(ListItem3,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_UNSEL));
LISTBOX_SetString(ListItem3,"",tmp_expert_idx);
LISTBOX_DeleteItem(ListItem3,tmp_expert_idx);
if(btn_horz==1)
{
WM_ShowWindow(Btnexp[0]);
WM_ShowWindow(Btnexp[1]);
WM_ShowWindow(Btnexp[2]);
}
mode_EP_navigation=1;
WM_SetFocus(ListItem3);
//CreateHunt_page_two();
}
else
{
tmp = LISTBOX_GetSel(ListItem);
tmp16 = get_nd_item_dir(current_dogg->tree.DirTree,global_node,tmp);
if(tmp_expert_idx<50)
{
tmp_expert[tmp_expert_idx++]=tmp16;
if(tmp16)
{
CreateHunt_page_two();
}
}
}
}
else if (menu_page==MENU_FavorriteSounds)
{
count=LISTBOX_GetSel(ListItem);
tmpb=LISTBOX_GetNumItems(listFavorites)-1;
for(tmp=count;tmp<tmpb;tmp++)
{
LISTBOX_GetItemText(listFavorites,tmp+1,intsBuff,Max_stringlen);
intsBuff[Max_stringlen-1]=0;
LISTBOX_SetString(listFavorites,intsBuff,tmp);
}
LISTBOX_DeleteItem(listFavorites,tmpb);
SaveChangeFavorite();
FavoriteSounds_page();
}
else
{
tmp = LISTBOX_GetSel(ListItem);
tmp16 = get_nd_item_dir(current_dogg->tree.DirTree,global_node,tmp);
get_node_item(current_dogg->tree.DirTree,global_node,tmp,&p,&file_type);
quit_extension(p,intsBuff,sizeof(intsBuff));
LISTBOX_AddString(listFavorites,intsBuff);
SaveChangeFavorite();
Dialog_Now(&bmok,"Successful\nAdded to Favorites!");
}
sub_expert_menu=0;
break;
case 3://add favorite from expert hurts
if((menu_page==MENU_ExpertHunts)&&(!reading_mode_option))
{
tmp = LISTBOX_GetSel(ListItem);
LISTBOX_GetItemText(ListItem,tmp,intsBuff,Max_stringlen);
intsBuff[Max_stringlen-1]=0;
LISTBOX_AddString(listFavorites,intsBuff);
SaveChangeFavorite();
Dialog_Now(&bmok,"Successful\nAdded to Favorites!");
}
break;
}
}
void hunt_option_list(u8 funtion)
{
char intsBuff[Max_stringlen];
vu8 tmp,count,tmpb;
vu16 tmp16;
char *p;
u8 file_type;
switch(funtion)
{
default:
sound_info.state = SOUND_STOPPED;
sound_info.current_time =0;
break;
case 0://play
if(sound_info.state == SOUND_STOPPED)
list_play_file();
else
file_play_pause();
break;
case 1://add to favorite
tmp = LISTBOX_GetSel(ListItem);
tmp16 = get_nd_item_dir(current_dogg->tree.DirTree,global_node,tmp);
get_node_item(current_dogg->tree.DirTree,global_node,tmp,&p,&file_type);
quit_extension(p,intsBuff,sizeof(intsBuff));
LISTBOX_AddString(listFavorites,intsBuff);
SaveChangeFavorite();
Dialog_Now(&bmok,"Successful\nAdded to Favorites!");
sub_expert_menu=0;
break;
case 2:
break;
case 3:
break;
}
}
void favorate_option_list(u8 funtion)
{
char intsBuff[Max_stringlen];
vu8 tmp,count,tmpb;
vu16 tmp16;
switch(funtion)
{
case 0://play
if(sound_info.state == SOUND_STOPPED)
list_play_file();
else
file_play_pause();
break;
case 1://add to expert hunt
if(sub_expert_menu)
{
WM_HideWindow(ListItem2);
list2_funtion=0;
if(!mode_EP_navigation)
{
if(tmp_expert_idx>(selected_itemexpert+1))
{
for(tmp=selected_itemexpert;tmp<(tmp_expert_idx-selected_itemexpert);tmp++)
{
tmp_expert[tmp]=tmp_expert[tmp+1];
LISTBOX_GetItemText(ListItem3,tmp+1,intsBuff,30);
intsBuff[29]=0;
LISTBOX_SetString(ListItem3,intsBuff,tmp);
}
}
if(selected_itemexpert)selected_itemexpert--;
if(tmp_expert_idx)LISTBOX_SetSel(ListItem3,selected_itemexpert);
tmp_expert_idx--;
if(!tmp_expert_idx)LISTBOX_SetBkColor(ListItem3,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_UNSEL));
LISTBOX_SetString(ListItem3,"",tmp_expert_idx);
LISTBOX_DeleteItem(ListItem3,tmp_expert_idx);
if(btn_horz==1)
{
WM_ShowWindow(Btnexp[0]);
WM_ShowWindow(Btnexp[1]);
WM_ShowWindow(Btnexp[2]);
}
mode_EP_navigation=1;
WM_SetFocus(ListItem3);
//CreateHunt_page_two();
}
else
{
tmp = LISTBOX_GetSel(ListItem);
tmp16 = get_nd_item_dir(current_dogg->tree.DirTree,global_node,tmp);
if(tmp_expert_idx<50)
{
tmp_expert[tmp_expert_idx++]=tmp16;
if(tmp16)
{
CreateHunt_page_two();
}
}
}
}
else if (menu_page==MENU_FavorriteSounds)
{
count=LISTBOX_GetSel(ListItem);
tmpb=LISTBOX_GetNumItems(listFavorites)-1;
for(tmp=count;tmp<tmpb;tmp++)
{
LISTBOX_GetItemText(listFavorites,tmp+1,intsBuff,Max_stringlen);
intsBuff[Max_stringlen-1]=0;
LISTBOX_SetString(listFavorites,intsBuff,tmp);
}
LISTBOX_DeleteItem(listFavorites,tmpb);
SaveChangeFavorite();
FavoriteSounds_page();
}
sub_expert_menu=0;
break;
case 2:// delete
break;
}
}
void Sounds_page(void);
void enter_DirList(void)
{
u8 select;
u16 tmp16;
char *name;
u8 file_type;
DOGG_Type * p_dogg;
path_type * P_path;
p_dogg = &dogg[speaker];
select = LISTBOX_GetSel(ListItem);
file_type = list_attr[select].type;
name = (char *)(p_dogg->tree.DirTree + FLASH_DATA_STARTADDR + list_attr[select].node);
if(file_type == Type_Folder)//folder
{
P_path = &current_path[folderdeep];
P_path->index = select;
if(++folderdeep >= Max_depth)return;
//查找对应段
tmp16 = get_NodeBase1(p_dogg->tree.DirTree,list_attr[select].node);
if(tmp16==0xffff)return;
P_path ++;
P_path->node =tmp16;
strcpy(P_path->name,name);
global_node = tmp16;
//列表显示
TEXT_SetText(MainTitle, name);
WM_SetFocus(ListItem);
list_draw_childs(current_dogg->tree.DirTree,tmp16);
LISTBOX_SetSel(ListItem,0);
}
else if(file_type == Type_file)//文件
{
if(btn_horz==1)//expert Hunts编辑
{
tmp16 = get_nd_item_dir(p_dogg->tree.DirTree,global_node,select);
if(tmp_expert_idx < EpertHunt_MAX)
{
tmp_expert[tmp_expert_idx++]=tmp16;
if(tmp16)
{
CreateHunt_page_two();
}
}
}else if(list2_funtion==0){
ListItem2_popup(2);
LISTBOX_SetString(ListItem2,"Play",0);
LISTBOX_SetString(ListItem2,"Add Favorite",1);
LISTBOX_SetSel(ListItem2,0);
list2_funtion=1;
}else {
select = LISTBOX_GetSel(ListItem2);
folder_option_list(select);
}
}
}
void exit_DirList(void)
{
path_type * p;
if(list2_funtion)
{
WM_HideWindow(ListItem2);
list2_funtion=0;
WM_SetFocus(ListItem);
}
else if(folderdeep == 0)
{
Sounds_page();
LISTBOX_SetSel(ListItem,0);
}
else
{
ListItem_clear_item();
folderdeep--;
p = &current_path[folderdeep];
if(folderdeep == 0){
TEXT_SetText(MainTitle, "All Sounds");
}else{
TEXT_SetText(MainTitle, p->name);
}
list_draw_childs(current_dogg->tree.DirTree,p->node);
LISTBOX_SetSel(ListItem,p->index);
}
}
void WM_HideSubWin(void)
{
u8 tmp;
for(tmp=0;tmp<8;tmp++)WM_HideWindow(BtnWin[tmp]);
WM_HideWindow(ScrollWin);
WM_HideWindow(ProgWin);
WM_HideWindow(TextWin[0]);
WM_HideWindow(TextWin[1]);
WM_HideWindow(TextWin[2]);
WM_HideWindow(WIN_SLIDER_BASS);
WM_HideWindow(WIN_SLIDER_TREBLE);
WM_HideWindow(ListItem2);list2_funtion=0;
WM_HideWindow(EditWin1);
if(btn_horz)
{
btn_horz=0;
WM_HideWindow(Btnexp[0]);
WM_HideWindow(Btnexp[1]);
WM_HideWindow(Btnexp[2]);
}
WM_HideWindow(ListItem3);
}
void ListItem_reset_default_style(void)
{
if(keyboard_en)
{
keyboard_en=0;
GUI_EndDialog(hKeyboard,0);
}
WM_HideWindow(Logo_window);
WM_HideSubWin();
TEXT_SetFont(MainTitle, GUI_FONT_32S);
WM_ShowWindow(MainTitle);
LISTBOX_SetFont(ListItem, GUI_FONT_28K);
LISTBOX_SetItemSpacing(ListItem,0);
LISTBOX_SetTextAlign(ListItem, GUI_TA_HCENTER|GUI_TA_VCENTER);
WM_ShowWindow(ListItem);
WM_SetFocus(ListItem);
LISTBOX_SetItemDisabled(ListItem,0,0);
LISTBOX_SetItemDisabled(ListItem,1,0);
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_TEXT_LIST));
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_SEL,get_color_NightMode(COLOR_TEXT_LIST));
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_TEXT_LIST));
LISTBOX_SetBackColor(ListItem,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_ListItem_UNSEL));
LISTBOX_SetBackColor(ListItem,LISTBOX_CI_SEL,get_color_NightMode(COLOR_ListItem_UNFORCE));
LISTBOX_SetBackColor(ListItem,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_SELECTED));
}
void homepage(void)
{
//u8 tmp;
//resize_spk_lits(ActiveDoggsNumber);
WM_HideWindow(MainTitle);
WM_HideWindow(ListItem);
WM_HideWindow(ScrollUpWin);
WM_HideWindow(ScrollDownWin);
WM_HideSubWin();
WM_ShowWindow(Logo_window);//logo
WM_SetFocus(ListItem_doggs);
speaker = LISTBOX_GetSel(ListItem_doggs);
current_menu=menu_page=MENU_home;
}
void MainMenu_page(u8 reset){
menu_page=MENU_MainMenu;
ListItem_reset_default_style();
ListItem_SetItumTo(4);
TEXT_SetText(MainTitle,"Main Menu");
LISTBOX_SetString(ListItem, "Sounds",0);
LISTBOX_SetString(ListItem, "Expert Hunts",1);
LISTBOX_SetString(ListItem, "Settings",2);
LISTBOX_SetString(ListItem, "Sync Settings",3);
if(MainMenuHideItem)
{
LISTBOX_SetItemDisabled(ListItem,0,1);
LISTBOX_SetItemDisabled(ListItem,1,1);
if(reset || LISTBOX_GetSel(ListItem)<2)ListIndex[MENU_MainMenu]=2;
}
else
{
if(reset)ListIndex[MENU_MainMenu]=0;
}
LISTBOX_SetSel(ListItem, ListIndex[MENU_MainMenu]);
}
void PlaySounds_page(void)
{
ListItem_reset_default_style();
ListItem_SetItumTo(3);
menu_page=MENU_Sounds;
TEXT_SetText(MainTitle,"Select the sound from");
LISTBOX_SetString(ListItem, "All Sounds",0);
LISTBOX_SetString(ListItem, "Expert hunt",1);
LISTBOX_SetString(ListItem, "Favorite Sounds",2);
ListIndex[menu_page]=0;
LISTBOX_SetSel(ListItem,ListIndex[menu_page]);
reading_mode_option=1;
}
void Sounds_page(void)
{
ListItem_reset_default_style();
menu_page=MENU_Sounds;
ListItem_SetItumTo(2);
TEXT_SetText(MainTitle,"Sounds");
LISTBOX_SetString(ListItem, "All Sounds",0);
LISTBOX_SetString(ListItem, "Favorite Sounds",1);
}
uint32_t CRC_CalcBlockCRC_SPI_FLASH(uint32_t add, uint32_t BufferLength)
{
#define FLASH_READ_SIZE 64
uint32_t index = 0;
u8 k;
u8 pBuffer[FLASH_READ_SIZE];
u32 * p32;
while(1)
{
SPI_FLASH_BufferRead(pBuffer, add, FLASH_READ_SIZE);
p32 = (u32 *)pBuffer;
for(k=0;k<(FLASH_READ_SIZE/4);k++)
{
CRC->DR = *p32++;
if(++index >= BufferLength)return (CRC->DR);
}
add += FLASH_READ_SIZE;
}
}
const char * get_DoggTypeString(u8 type)
{
if(type == 1)return (const char *)"Top";
else if(type == 2)return (const char *)"Horn";
else if(type == 3)return (const char *)"Triple";
else return (const char *)"Unknow";
}
void SyncSettings_page(u8 reset)
{
u8 tmp,tmp16;
char intsBuff[50];
DOGG_Type * p_dogg;
WM_HideSubWin();
if(menu_page == MENU_MainMenu || menu_page == MENU_Setting)last_menu = menu_page;
menu_page=MENU_SyncSettings;
ListItem_reset_default_style();
ListItem_SetItumTo(1);
tmp16=offset_list_ypx+95;
WM_SetWindowPos(ProgWin, 20,tmp16, 200, 15);
WM_SetWindowPos(TextWin[1], 20,tmp16+25,200, 20);
TEXT_SetTextAlign(TextWin[1],TEXT_CF_VCENTER | TEXT_CF_HCENTER);
TEXT_SetTextColor(TextWin[1], get_color_NightMode(COLOR_TEXT_LIST));
TEXT_SetFont(TextWin[1],GUI_FONT_16B_1);
LISTBOX_SetString(ListItem, "Synchronize Now",0);
for(tmp=0;tmp < Doggs_List_MAX;tmp++)
{
p_dogg = &dogg[tmp];
if(check_dogg_online(p_dogg,0xff))
{
sprintf(intsBuff,"%s Dogg %04X - %s",get_DoggTypeString(p_dogg->doggtype),p_dogg->ID,(p_dogg->MemState & Dogg_SYNCED_MASK)?"ok":"error");
LISTBOX_AddString(ListItem, intsBuff);
}
}
if(reset){
LISTBOX_SetSel(ListItem,0);
ListIndex[menu_page]=0;
}
TEXT_SetText(MainTitle,"Sync settings");
TEXT_SetText(TextWin[1],"");
}
void Settings_page(u8 reset)
{
WM_HideSubWin();
menu_page=MENU_Setting;
ListItem_reset_default_style();
ListItem_SetItumTo(6);
TEXT_SetText(MainTitle,"Settings");
LISTBOX_SetString(ListItem, "Sound Settings",0);
LISTBOX_SetString(ListItem, "Display Settings",1);
LISTBOX_SetString(ListItem, "Device Info",2);
LISTBOX_SetString(ListItem, "HotKey Settings",3);
LISTBOX_SetString(ListItem, "Sync Settings",4);
LISTBOX_SetString(ListItem, "My Doggs",5);
#ifdef DECOY_SETTING
LISTBOX_InsertString(ListItem, "Decoy Settings",1);
#endif
if(reset)ListIndex[MENU_Setting]=0;
LISTBOX_SetSel(ListItem, ListIndex[MENU_Setting]);
}
void SelectSpeaker_page(void)
{
menu_page=MENU_SelectSpeaker;
ListItem_reset_default_style();
ListItem_SetItumTo(0);
LISTBOX_SetSel(ListItem,0);
TEXT_SetText(MainTitle,"Select Speaker");
LISTBOX_SetString(ListItem, "Top Dogg",0);
LISTBOX_SetString(ListItem, "Horn Dogg",1);
LISTBOX_SetString(ListItem, "Triple Dogg",2);
}
void FavoriteSounds_page(void)
{
u8 tmp;
char intsBuff[50];
menu_page=MENU_FavorriteSounds;
ListIndex[MENU_FavorriteSounds]=0;
ListItem_reset_default_style();
ListItem_clear_item();
LISTBOX_SetSel(ListItem,0);
tmp = draw_favorites();
sprintf(intsBuff,"Favorite Sounds(%u)",tmp);
TEXT_SetText(MainTitle,intsBuff);
}
void ExpertHunts_page(void )
{
u8 count;
char intsBuff[50];
menu_page=MENU_ExpertHunts;
ListItem_reset_default_style();
ListItem_clear_item();
LISTBOX_SetSel(ListItem,0);
count = draw_expert_list();
sprintf(intsBuff,"Existing Hunts(%u)",count);
TEXT_SetText(MainTitle,intsBuff);
LISTBOX_AddString(ListItem, "Create New");
}
void CreateHunt_page_two(void)
{
vu8 tmp,count;
char *p;
char intsBuff[30];
show_one_bar=1;
icon_refresh(0);
GUI_Delay(1);
WM_HideWindow(TextWin[2]);
WM_HideWindow(EditWin1);
WM_HideWindow(TextWin[0]);
WM_HideWindow(TextWin[1]);
WM_ShowWindow(ListItem3);
WM_SetWindowPos(ListItem3, 0, offset_list_ypx, 240, 250-offset_list_ypx);
//WM_HideWindow(ListItem);
sprintf(intsBuff,"Expert Hunt List(%u)",tmp_expert_idx);
TEXT_SetText(MainTitle,intsBuff);
menu_page=MENU_CreatHunt2;
mode_EP_navigation=1;
if(tmp_expert_idx==0)// no elements
{
tmp =LISTBOX_GetNumItems(ListItem3);
while(tmp)
{
LISTBOX_SetString(ListItem3,"",--tmp);
LISTBOX_DeleteItem(ListItem3,tmp);
}
}
tmp =LISTBOX_GetNumItems(ListItem3);
WM_SetFocus(ListItem3);
if(tmp_expert_idx!=tmp)// new element
{
WM_HideWindow(ListItem2);
list2_funtion=0;
p=(char *)((current_dogg->tree.DirTree) + tmp_expert[tmp]);
quit_extension(p,intsBuff,sizeof(intsBuff));
LISTBOX_AddString(ListItem3,"");
LISTBOX_SetSel(ListItem3,LISTBOX_GetNumItems(ListItem)-1);
}
for(tmp=0;tmp<3;tmp++)
{
BUTTON_SetBkColor(Btnexp[tmp],BUTTON_CI_UNPRESSED,get_color_NightMode(COLOR_BTN_UNSEL));
BUTTON_SetBkColor(Btnexp[tmp],BUTTON_CI_PRESSED,get_color_NightMode(COLOR_ListItem_SELECTED));
if(tmp==0)BUTTON_SetText(Btnexp[tmp],"Add");
if(tmp==1)BUTTON_SetText(Btnexp[tmp],"Play");
if(tmp==2)BUTTON_SetText(Btnexp[tmp],"Save");
WM_ShowWindow(Btnexp[tmp]);
}
if(tmp_expert_idx==50)
{
WM_DisableWindow(Btnexp[0]);
btn_low=2;
}
else
{
btn_horz=1;
}
BUTTON_SetPressed(Btnexp[btn_horz-1],1);
BUTTON_SetPressed(Btnexp[1],0);
BUTTON_SetPressed(Btnexp[2],0);
LISTBOX_SetBkColor(ListItem3,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_UNSEL));
}
void CreateHunt_page(void)
{
u16 tmp,tmp16;
const GUI_FONT * font;
tmp_expert_idx=0;
tmp_expert[tmp_expert_idx]=0;
tmp =LISTBOX_GetNumItems(ListItem3);
while(tmp>0)
{
LISTBOX_DeleteItem(ListItem3,tmp-1);
tmp--;
}
menu_page=MENU_CreatHuntName;
ListItem_reset_default_style();
show_one_bar=1;
icon_refresh(0);
GUI_Delay(1);
TEXT_SetText(MainTitle,"Create Hunt");
font = LISTBOX_GetFont(ListItem);
LISTBOX_SetItemSpacing(ListItem,SettingsLine_Y-font->YSize);
LISTBOX_SetTextAlign(ListItem, GUI_TA_HCENTER|GUI_TA_VCENTER);
ListItem_SetItumTo(0);
LISTBOX_SetString(ListItem, "",0);
//LISTBOX_SetSel(ListItem,0);
for(tmp=0;tmp<30;tmp++){
tmp_expert[tmp]=0;
}
ListIndex[menu_page]=0;
keyboard_en=0;
btn_horz=0;
tmp16 = offset_list_ypx+10;
WM_SetWindowPos(TextWin[0], 5,tmp16, 100, 20);
TEXT_SetText(TextWin[0],"Name");
WM_ShowWindow(TextWin[0]);
WM_SetWindowPos(EditWin1, 100,tmp16, 120, 20);
EDIT_SetMaxLen(EditWin1,20);
EDIT_SetText(EditWin1,"");
WM_ShowWindow(EditWin1);
//弹出键盘
keyboard_popup();
WM_SetStayOnTop(hKeyboard, 1);
}
void get_EQ_type_string(u8 type, char *p){
if(type == 0)
strcpy(p, "Hunt");
else if (type == 1)
strcpy(p, "Dynamic Hunt");
else
strcpy(p, "Music");
}
void SoundSettings_page(u8 reset)
{
char intsBuff[32];
u8 tmp16;
u32 color,color_sel;
s8 vol;
const GUI_FONT * font;
menu_page=MENU_SoundSettings;
if(reset){
tmp_adj[0] = (current_dogg->setting & STATE_BT_MASK)? 1: 0;
tmp_adj[1] = (current_dogg->setting & STATE_EQ_MASK);
tmp_adj[2] = (current_dogg->setting & STATE_LOOP_MASK)?1:0;
}
color= get_color_NightMode(COLOR_BTN_UNSEL);
color_sel= get_color_NightMode(COLOR_BTN_SELECTED);
tmp16=offset_list_ypx+SettingsLine_Y/2;//行中间位置
////////////////////////////
ListItem_reset_default_style();
TEXT_SetText(MainTitle,"Sound Settings");
LISTBOX_SetFont(ListItem, GUI_FONT_16B_1);
font = LISTBOX_GetFont(ListItem);
LISTBOX_SetItemSpacing(ListItem,SettingsLine_Y-font->YSize);
LISTBOX_SetTextAlign(ListItem, GUI_TA_LEFT|GUI_TA_VCENTER);
ListItem_SetItumTo(3);
LISTBOX_SetString(ListItem, " Speaker Mode",0);
LISTBOX_SetString(ListItem, " EQ Type",1);
LISTBOX_SetString(ListItem, " Loop",2);
////////////// // BT / SD
BUTTON_SetText(BtnWin[0], "SD");
BUTTON_SetText(BtnWin[1], "BT");
BUTTON_SetFont(BtnWin[0],GUI_FONT_16_1);
BUTTON_SetFont(BtnWin[1],GUI_FONT_16_1);
WM_SetWindowPos(BtnWin[0], 105,tmp16-10, 60, 20);
WM_SetWindowPos(BtnWin[1], 165,tmp16-10, 60, 20);
if(tmp_adj[0]==1)
{
BUTTON_SetBkColor(BtnWin[1],BUTTON_CI_UNPRESSED,color_sel);
BUTTON_SetBkColor(BtnWin[0],BUTTON_CI_UNPRESSED,color);
}
else
{
BUTTON_SetBkColor(BtnWin[0],BUTTON_CI_UNPRESSED,color_sel);
BUTTON_SetBkColor(BtnWin[1],BUTTON_CI_UNPRESSED,color);
}
WM_ShowWindow(BtnWin[0]);
WM_ShowWindow(BtnWin[1]);
////////////////
tmp16+= SettingsLine_Y;
get_EQ_type_string(tmp_adj[1],intsBuff);
TEXT_SetText(TextWin[0],intsBuff);
WM_SetWindowPos(TextWin[0], 105,tmp16-10, 120, 20);
TEXT_SetTextAlign(TextWin[0],TEXT_CF_VCENTER | TEXT_CF_LEFT);
TEXT_SetTextColor(TextWin[0], get_color_NightMode(COLOR_TEXT_LIST));
TEXT_SetFont(TextWin[0],GUI_FONT_16_1);
WM_ShowWindow(TextWin[0]);
//////
tmp16+= SettingsLine_Y;
BUTTON_SetText(BtnWin[2], "Y");
BUTTON_SetText(BtnWin[3], "N");
BUTTON_SetFont(BtnWin[2],GUI_FONT_16_1);
BUTTON_SetFont(BtnWin[3],GUI_FONT_16_1);
WM_SetWindowPos(BtnWin[2], 105,tmp16-10, 60, 20);
WM_SetWindowPos(BtnWin[3], 165,tmp16-10, 60, 20);
if(tmp_adj[2]==0)// Y / N
{
BUTTON_SetBkColor(BtnWin[2],BUTTON_CI_UNPRESSED,color);
BUTTON_SetBkColor(BtnWin[3],BUTTON_CI_UNPRESSED,color_sel);
}
else
{
BUTTON_SetBkColor(BtnWin[3],BUTTON_CI_UNPRESSED,color);
BUTTON_SetBkColor(BtnWin[2],BUTTON_CI_UNPRESSED,color_sel);
}
WM_ShowWindow(BtnWin[2]);
WM_ShowWindow(BtnWin[3]);
//////////////
if(current_dogg->doggtype !=3)
{
tmp16+= SettingsLine_Y;
if(current_dogg->SubwooferVol< -BASS_TREBLE_MAX || current_dogg->SubwooferVol>BASS_TREBLE_MAX)
current_dogg->SubwooferVol=0;
if(current_dogg->TweeterVol< -BASS_TREBLE_MAX || current_dogg->TweeterVol>BASS_TREBLE_MAX)
current_dogg->TweeterVol=0;
LISTBOX_AddString(ListItem," Adjust Bass");
LISTBOX_AddString(ListItem," Adjust Treble");
WM_SetWindowPos(WIN_SLIDER_BASS, 125,tmp16-8, 100, 16);
SLIDER_SetTickColor(WIN_SLIDER_BASS, get_color_NightMode(COLOR_TEXT_LIST));
SLIDER_SetBarColor(WIN_SLIDER_BASS, GUI_DARKGRAY);
SLIDER_SetValue(WIN_SLIDER_BASS, current_dogg->SubwooferVol);
WM_ShowWindow(WIN_SLIDER_BASS);
WM_SetWindowPos(TextWin[1], 95,tmp16-10, 20, 20);
vol = SLIDER_GetValue(WIN_SLIDER_BASS);
if(vol >0)
sprintf(intsBuff,"+%d",vol);
else
sprintf(intsBuff,"%d",vol);
TEXT_SetText(TextWin[1],intsBuff);
TEXT_SetTextAlign(TextWin[1],TEXT_CF_VCENTER | TEXT_CF_RIGHT);
TEXT_SetTextColor(TextWin[1], get_color_NightMode(COLOR_TEXT_LIST));
TEXT_SetFont(TextWin[1],GUI_FONT_13_1);
WM_ShowWindow(TextWin[1]);
tmp16+= SettingsLine_Y;
WM_SetWindowPos(WIN_SLIDER_TREBLE, 125,tmp16-8, 100, 16);
SLIDER_SetTickColor(WIN_SLIDER_TREBLE, get_color_NightMode(COLOR_TEXT_LIST));
SLIDER_SetBarColor(WIN_SLIDER_TREBLE, GUI_DARKGRAY);
SLIDER_SetValue(WIN_SLIDER_TREBLE,current_dogg->TweeterVol);
WM_ShowWindow(WIN_SLIDER_TREBLE);
WM_SetWindowPos(TextWin[2], 95,tmp16-10, 20, 20);
vol = SLIDER_GetValue(WIN_SLIDER_TREBLE);
if(vol >0)
sprintf(intsBuff,"+%d",vol);
else
sprintf(intsBuff,"%d",vol);
TEXT_SetText(TextWin[2],intsBuff);
TEXT_SetTextAlign(TextWin[2],TEXT_CF_VCENTER | TEXT_CF_RIGHT);
TEXT_SetTextColor(TextWin[2], get_color_NightMode(COLOR_TEXT_LIST));
TEXT_SetFont(TextWin[2],GUI_FONT_13_1);
WM_ShowWindow(TextWin[2]);
}
else
{
WM_HideWindow(TextWin[1]);
WM_HideWindow(TextWin[2]);
WM_HideWindow(WIN_SLIDER_BASS);
WM_HideWindow(WIN_SLIDER_TREBLE);
}
if(reset){
ListIndex[menu_page]=0;
scroll_pos=0;
}
LISTBOX_SetSel(ListItem,ListIndex[menu_page]);
}
void DecoySettings_page(void)
{
u16 tmp,tmp16;
char strbuf[32];
const GUI_FONT * font;
menu_page=MENU_DecoySettings;
ListItem_reset_default_style();
LISTBOX_SetFont(ListItem, GUI_FONT_16B_1);
font = LISTBOX_GetFont(ListItem);
LISTBOX_SetItemSpacing(ListItem,SettingsLine_Y-font->YSize);
LISTBOX_SetTextAlign(ListItem, GUI_TA_LEFT|GUI_TA_VCENTER);
TEXT_SetText(MainTitle,"Decoy Settings");
tmp16=offset_list_ypx+SettingsLine_Y/2;
#if 0
ListItem_SetItumTo(2);
LISTBOX_SetString(ListItem, " Pairing",0);
LISTBOX_SetString(ListItem, " Speed",1);
WM_SetWindowPos(BtnWin[6], 100,tmp16-10,60,20);
WM_SetWindowPos(BtnWin[7], 160,tmp16-10,60,20);
BUTTON_SetFont(BtnWin[6],GUI_FONT_16_1);
BUTTON_SetFont(BtnWin[7],GUI_FONT_16_1);
BUTTON_SetText(BtnWin[6], "BT");
BUTTON_SetText(BtnWin[7], "Wire");
tmp_adj[0] = decoy_link;
if(tmp_adj[0] == 1)
{
BUTTON_SetBkColor(BtnWin[6],BUTTON_CI_UNPRESSED,get_color_NightMode(COLOR_BTN_UNSEL));
BUTTON_SetBkColor(BtnWin[7],BUTTON_CI_UNPRESSED,get_color_NightMode(COLOR_BTN_SELECTED));
}
else
{
BUTTON_SetBkColor(BtnWin[7],BUTTON_CI_UNPRESSED,get_color_NightMode(COLOR_BTN_UNSEL));
BUTTON_SetBkColor(BtnWin[6],BUTTON_CI_UNPRESSED,get_color_NightMode(COLOR_BTN_SELECTED));
}
WM_ShowWindow(BtnWin[6]);
WM_ShowWindow(BtnWin[7]);
tmp16 +=SettingsLine_Y;
#else
ListItem_SetItumTo(1);
LISTBOX_SetString(ListItem, " Speed",0);
#endif
for(tmp=0;tmp<6;tmp++)
{
WM_SetWindowPos(BtnWin[tmp], tmp*27+68,tmp16-11,22,22);
BUTTON_SetFont(BtnWin[tmp],GUI_FONT_16_1);
sprintf(strbuf,"%u",tmp);
BUTTON_SetText(BtnWin[tmp], strbuf);
BUTTON_SetBkColor(BtnWin[tmp],BUTTON_CI_UNPRESSED,get_color_NightMode(COLOR_BTN_UNSEL));
WM_ShowWindow(BtnWin[tmp]);
}
BUTTON_SetBkColor(BtnWin[decoy_speed],BUTTON_CI_UNPRESSED,get_color_NightMode(COLOR_BTN_SELECTED));
}
void DisplaySettings_page(u8 reset)
{
u16 tmp16;
u32 color,color_sel;
const GUI_FONT * font;
WM_HideSubWin();
if(reset){
tmp_adj[0] = main_coff.night_mode;
#ifdef FONT_SIZE
tmp_adj[1] = main_coff.font_size;
#endif
tmp_adj[2] = timer_enable;
}
tmp16=offset_list_ypx+SettingsLine_Y/2;
menu_page=MENU_DisplaySettings;
ListItem_reset_default_style();
LISTBOX_SetFont(ListItem, GUI_FONT_16B_1);
font = LISTBOX_GetFont(ListItem);
LISTBOX_SetItemSpacing(ListItem,SettingsLine_Y-font->YSize);
LISTBOX_SetTextAlign(ListItem, GUI_TA_LEFT|GUI_TA_VCENTER);
TEXT_SetText(MainTitle,"Display Settings");
LISTBOX_SetString(ListItem, " Display",0);
#ifdef FONT_SIZE
ListItem_SetItumTo(4);
LISTBOX_SetString(ListItem, " Font size",1);
LISTBOX_SetString(ListItem, " Timer",2);
LISTBOX_SetString(ListItem, " Brightness",3);
#else
ListItem_SetItumTo(3);
LISTBOX_SetString(ListItem, " Timer",1);
LISTBOX_SetString(ListItem, " Brightness",2);
#endif
LISTBOX_SetSel(ListItem,ListIndex[MENU_DisplaySettings]);
//night
BUTTON_SetFont(BtnWin[0],GUI_FONT_16_1);
BUTTON_SetFont(BtnWin[1],GUI_FONT_16_1);
BUTTON_SetText(BtnWin[0], "Regular");
BUTTON_SetText(BtnWin[1], "Night Mode");
WM_SetWindowPos(BtnWin[0], 92,tmp16-10,63,20);
WM_SetWindowPos(BtnWin[1], 160,tmp16-10,70,20);
color= get_color_NightMode(COLOR_BTN_UNSEL);
color_sel= get_color_NightMode(COLOR_BTN_SELECTED);
if(tmp_adj[0])
{
BUTTON_SetBkColor(BtnWin[0],BUTTON_CI_UNPRESSED,color);
BUTTON_SetBkColor(BtnWin[1],BUTTON_CI_UNPRESSED,color_sel);
}
else
{
BUTTON_SetBkColor(BtnWin[1],BUTTON_CI_UNPRESSED,color);
BUTTON_SetBkColor(BtnWin[0],BUTTON_CI_UNPRESSED,color_sel);
}
WM_ShowWindow(BtnWin[0]);
WM_ShowWindow(BtnWin[1]);
#ifdef FONT_SIZE
tmp16 += SettingsLine_Y;
BUTTON_SetText(BtnWin[2], "Small");
BUTTON_SetFont(BtnWin[2],GUI_FONT_10_1);
BUTTON_SetText(BtnWin[3], "Medium");
BUTTON_SetFont(BtnWin[3],GUI_FONT_16_1);
BUTTON_SetText(BtnWin[4], "Large");
BUTTON_SetFont(BtnWin[4],GUI_FONT_16B_1);
WM_SetWindowPos(BtnWin[2], 92,tmp16-10,41,20);
WM_SetWindowPos(BtnWin[3], 138,tmp16-10,45,20);
WM_SetWindowPos(BtnWin[4], 188,tmp16-10,43,20);
BUTTON_SetBkColor(BtnWin[2],BUTTON_CI_UNPRESSED,color);
BUTTON_SetBkColor(BtnWin[3],BUTTON_CI_UNPRESSED,color);
BUTTON_SetBkColor(BtnWin[4],BUTTON_CI_UNPRESSED,color);
BUTTON_SetBkColor(BtnWin[2+tmp_adj[1]],BUTTON_CI_UNPRESSED,color_sel);
WM_ShowWindow(BtnWin[2]);
WM_ShowWindow(BtnWin[3]);
WM_ShowWindow(BtnWin[4]);
#endif
tmp16 += SettingsLine_Y;
// timer
BUTTON_SetFont(BtnWin[5],GUI_FONT_16_1);
BUTTON_SetFont(BtnWin[6],GUI_FONT_16_1);
BUTTON_SetFont(BtnWin[7],GUI_FONT_16_1);
BUTTON_SetText(BtnWin[5], "On");
BUTTON_SetText(BtnWin[6], "Off");
BUTTON_SetText(BtnWin[7], "Reset");
WM_SetWindowPos(BtnWin[5], 92,tmp16-10,41,20 );
WM_SetWindowPos(BtnWin[6], 138,tmp16-10,45,20 );
WM_SetWindowPos(BtnWin[7], 188,tmp16-10,43,20 );
BUTTON_SetBkColor(BtnWin[5],BUTTON_CI_UNPRESSED,color);//OFF
BUTTON_SetBkColor(BtnWin[6],BUTTON_CI_UNPRESSED,color);//ON
BUTTON_SetBkColor(BtnWin[7],BUTTON_CI_UNPRESSED,color);//RESET
BUTTON_SetBkColor(BtnWin[5+tmp_adj[2]],BUTTON_CI_UNPRESSED,color_sel);
WM_ShowWindow(BtnWin[5]);
WM_ShowWindow(BtnWin[6]);
WM_ShowWindow(BtnWin[7]);
// brightness
WM_SetWindowPos(ScrollWin, 95,tmp16+(SettingsLine_Y-8),130,16);
SCROLLBAR_SetValue(ScrollWin,brightness);
WM_ShowWindow(ScrollWin);
if(reset){
ListIndex[menu_page]=0;
scroll_pos=0;
}
LISTBOX_SetSel(ListItem,ListIndex[menu_page]);
}
void MyDoggs_page(u8 reset)
{
u8 k;
char str[32];
DOGG_registed * p_reg;
if(menu_page == MENU_GoPage || menu_page == MENU_Setting)last_menu = menu_page;
menu_page=MENU_MyDoggs;
ListItem_reset_default_style();
TEXT_SetText(MainTitle,"My Doggs");
ListItem_SetItumTo(1);
LISTBOX_SetString(ListItem, "Add New",0);
for(k=0;k < Doggs_REG_MAX;k++)
{
p_reg = &registed_dogg[k];
if(*p_reg->name != 0xff && *p_reg->name != 0)
{
sprintf(str,"%s Dogg-%04X \"%s\"",get_DoggTypeString(p_reg->doggtype),p_reg->ID,p_reg->name);
LISTBOX_AddString(ListItem, str);
}
}
LISTBOX_AddString(ListItem, "Sumit");
if(reset){
ListIndex[menu_page]=0;
scroll_pos=0;
}
LISTBOX_SetSel(ListItem,ListIndex[menu_page]);
}
void DoggsSelection_page(void)
{
u8 k,m;
char str[32];
char * p;
DOGG_Type * p_spk;
DOGG_registed * p_registed;
menu_page=MENU_AddDoggs;
TEXT_SetText(MainTitle,"Doggs Selection");
ListItem_clear_item();
WM_HideSubWin();
LISTBOX_SetFont(ListItem, GUI_FONT_16B_1);
ListItem_SetItumTo(1);
LISTBOX_SetSel(ListItem, 0);
LISTBOX_SetItemSpacing(ListItem,40-16);
LISTBOX_SetTextAlign(ListItem, GUI_TA_HCENTER|GUI_TA_VCENTER);
LISTBOX_SetString(ListItem, "",0);
WM_SetWindowPos(TextWin[0],0,WM_GetWindowOrgY(ListItem), 240, 40);
TEXT_SetFont(TextWin[0], GUI_FONT_16_1);
TEXT_SetTextAlign(TextWin[0], GUI_TA_VCENTER|GUI_TA_LEFT);
TEXT_SetTextColor(TextWin[0], get_color_NightMode(COLOR_TEXT_LIST));
TEXT_SetText(TextWin[0], "Please turn on earch spearker to add\nthen select one to configurate");
WM_ShowWindow(TextWin[0]);
p_spk = dogg;
for(k=0;k < Doggs_List_MAX;k++)
{
if(check_dogg_online(&dogg[k],0xff))
{
p_registed = registed_dogg;
for(m=0;m < Doggs_REG_MAX;m++)
{
if(p_spk->ID == p_registed->ID)break;
p_registed++;
}
if(m < Doggs_REG_MAX && registed_dogg[m].name[0] !=0 && registed_dogg[m].name[0] != 0xff)
{
strcpy(str,"Registed\n");
p = str + strlen(str);
sprintf(p,"%s Dogg-%04X \"%s\"",get_DoggTypeString(p_spk->doggtype),p_spk->ID,p_registed->name);
}
else
{
strcpy(str,"New Found\n");
p = str + strlen(str);
sprintf(p,"%s Dong-%04X",get_DoggTypeString(p_spk->doggtype),p_spk->ID);
}
LISTBOX_AddString(ListItem, str);
}
p_spk++;
}
}
void dogg_name_input_page(void)
{
u8 select,k,j;
u16 y;
DOGG_Type * p_spk;
DOGG_registed * p_registed;
const GUI_FONT * font;
char insbuff[Max_stringlen];
menu_page= MENU_EditDoggName;
ListItem_reset_default_style();
ListItem_SetItumTo(0);
font = LISTBOX_GetFont(ListItem);
LISTBOX_SetItemSpacing(ListItem,SettingsLine_Y-font->YSize);
LISTBOX_SetString(ListItem, "",0);
//LISTBOX_SetSel(ListItem,1); //不显示
select = ListIndex[MENU_AddDoggs];
p_spk = dogg;
j =0;
for(k=0;k < Doggs_List_MAX;k++)
{
if(check_dogg_online(&dogg[k],0xff))j++;
if(j == select)break;
p_spk++;
}
p_registed = registed_dogg;
for(k=0;k < Doggs_REG_MAX;k++)
{
if(p_spk->ID == p_registed->ID)break;
p_registed++;
}
sprintf(insbuff,"%s Dogg %04X",get_DoggTypeString(p_spk->doggtype),p_spk->ID);
TEXT_SetText(MainTitle, insbuff);
/////////////
TEXT_SetTextAlign(TextWin[0],TEXT_CF_VCENTER | TEXT_CF_LEFT);
TEXT_SetTextColor(TextWin[0], get_color_NightMode(COLOR_TEXT_LIST));
TEXT_SetFont(TextWin[0],GUI_FONT_16B_1);
TEXT_SetText(TextWin[0], "Dogg name");
y = offset_list_ypx+10;
WM_SetWindowPos(TextWin[0], 0, y, 100, 20);
WM_ShowWindow(TextWin[0]);
//编辑框
if(p_registed->name[0] == 0xff){
text_keyboard[0]=0;
//sprintf(text_keyboard,"%04X",p_spk->ID);
}else
{
strcpy(text_keyboard,p_registed->name);
}
EDIT_SetText(EditWin1, text_keyboard);
WM_SetWindowPos(EditWin1, 100, y, 120, 20);
EDIT_SetMaxLen(EditWin1,DoggNAME_MAX);
WM_ShowWindow(EditWin1);
//弹出键盘
keyboard_popup();
WM_SetStayOnTop(hKeyboard, 1);
}
const char RemoteControl_ver[] = VERSION "(" __DATE__ ")" ;
void set_SerialNumber_line(char * buf , u8 * p )
{
u8 tmp;
u16 tmp16 = (*(p+4) <<8)| *(p+5);
sprintf(buf, "\nS/N: 20%02u%02u%05u",(u16)*(p+2),(u16)*(p+3),tmp16);
tmp = *(p);
switch(tmp)
{
default:
buf[7]=' ';
buf[8]='0'+tmp%10;
break;
case 1:
buf[7]='W';
buf[8]='A';
break;
}
tmp = *(p+1);
switch(tmp)
{
case REMOTE:
buf[9]='W';
buf[10]='R';
break;
case TOP_DOGG:
buf[9]='T';
buf[10]='D';
break;
case HORN_DOGG:
buf[9]='H';
buf[10]='D';
break;
case TRIPLE_DOGG:
buf[9]='T';
buf[10]='R';
break;
case DECOY:
buf[9]='D';
buf[10]='C';
break;
default:
buf[9]='0'+tmp/10;
buf[10]='0'+tmp%10;
break;
}
}
void DeviceInfo_page(void)
{
u8 i;
char linebuf[32*3];
char *pstr;
const GUI_FONT * font;
menu_page=MENU_DeviceInfo;
ListItem_reset_default_style();
TEXT_SetText(MainTitle,"Device Info");
LISTBOX_SetFont(ListItem, GUI_FONT_16B_1);
font = LISTBOX_GetFont(ListItem);
LISTBOX_SetItemSpacing(ListItem,InfoLine_Y-font->YSize);
ListItem_SetItumTo(1);
LISTBOX_SetSel(ListItem,0);
scroll_pos=0;
///////////////////////////////////////////
//remote
sprintf(linebuf,"Remote Control");
pstr = linebuf + strlen(linebuf);
set_SerialNumber_line(pstr, (u8*)SN_FlashAddress);
pstr = linebuf + strlen(linebuf);
strcpy(pstr,"\nFW Version: ");
pstr = linebuf + strlen(linebuf);
strcpy(pstr,RemoteControl_ver);
LISTBOX_SetString(ListItem, linebuf,0);
///////////////////////////////////////////
for(i=0;i<Doggs_List_MAX;i++)
{
if(check_dogg_online(&dogg[i],0xff))
{
sprintf(linebuf,"%s Dogg ",get_DoggTypeString(dogg[i].doggtype));
pstr = linebuf + strlen(linebuf);
display_doggName2buffer(pstr, dogg[i].ID);
pstr = linebuf + strlen(linebuf);
set_SerialNumber_line(pstr,&dogg[i].manufacturer);
pstr = linebuf + strlen(linebuf);
strcpy(pstr,"\nFW Version: ");
pstr = linebuf + strlen(linebuf);
strcpy(pstr,dogg[i].FwVerssion);
LISTBOX_AddString(ListItem, linebuf);
}
}
///////////////////////////////////////////
#ifdef DECOY_SETTING
if(decoy_linked)
{
sprintf(linebuf,"Decoy Info");
pstr = linebuf + strlen(linebuf);
set_SerialNumber_line(pstr,&decoy_sn[0]);
pstr = linebuf + strlen(linebuf);
strcpy(pstr,"\nFW Version: ");
pstr = linebuf + strlen(linebuf);
strcpy(pstr,decoy_ver);
LISTBOX_AddString(ListItem, linebuf);
}
#endif
}
void SelectHotKey_page(void)
{
menu_page=MENU_HotKeySettings;
ListItem_reset_default_style();
TEXT_SetText(MainTitle,"HotKey Settings");
LISTBOX_SetFont(ListItem, GUI_FONT_28K);
LISTBOX_SetItemSpacing(ListItem,0);
ListItem_SetItumTo(4);
LISTBOX_SetString(ListItem, "Hot1",0);
LISTBOX_SetString(ListItem, "Hot2",1);
LISTBOX_SetString(ListItem, "Hot3",2);
LISTBOX_SetString(ListItem, "Hot4",3);
ListIndex[MENU_HotKeySettings] = 0;
LISTBOX_SetSel(ListItem, ListIndex[MENU_HotKeySettings]);
}
void hotkeySetting_page(void)
{
u8 index;
menu_page=MENU_Hotx;
ListItem_reset_default_style();
index = ListIndex[MENU_HotKeySettings];
switch(index)
{
case 0:TEXT_SetText(MainTitle,"Hot1");break;
case 1:TEXT_SetText(MainTitle,"Hot2");break;
case 2:TEXT_SetText(MainTitle,"Hot3");break;
case 3:TEXT_SetText(MainTitle,"Hot4");break;
}
ListItem_SetItumTo(1);
LISTBOX_SetString(ListItem, "Play Sound",0);
//LISTBOX_AddString(ListItem, "Activate Decoy");
LISTBOX_AddString(ListItem, "All Off");
LISTBOX_AddString(ListItem, "Night Mode");
LISTBOX_AddString(ListItem, "Settings Menu");
LISTBOX_AddString(ListItem, "Main Menu");
LISTBOX_SetSel(ListItem,main_coff.hotkey[index]);
}
void Select_Hotkey(void)
{
u8 hotky_index;
WM_HWIN BtnWW;
hotky_index = ListIndex[MENU_HotKeySettings];
if(hotky_index >3)return;
BtnWW=BtnHotkey[hotky_index];
main_coff.hotkey[hotky_index] = ListIndex[MENU_Hotx];
BUTTON_SetText(BtnWW,hotkey_string(ListIndex[MENU_Hotx]));
}
u8 menu_key(void){
if(menu_page == MENU_GoPage)return 0;
MainMenu_page(1);
return 0;
}
void nightmode_changeMode(void)
{
u8 i;
WINDOW_SetBkColor(main_window, get_color_NightMode(COLOR_BACK));
if(main_coff.night_mode){
TEXT_SetBkColor(Status_bar, (((u32)106<<16)|(153<<8)|255));//窗口(状态栏)背景颜色
BUTTON_SetBitmapEx(Logo_window,BUTTON_BI_UNPRESSED,&bmlogo2,20,120);
}else{
TEXT_SetBkColor(Status_bar, 0x2079f4); //RGB->BGR
BUTTON_SetBitmapEx(Logo_window,BUTTON_BI_UNPRESSED,&bmlogo,20,120);
}
BUTTON_SetBkColor(Logo_window,BUTTON_BI_UNPRESSED,get_color_NightMode(COLOR_BACK));
//状态栏
for(i=0;i<5;i++)
BUTTON_SetBkColor(TopStatusWin[i],BUTTON_BI_UNPRESSED,get_color_NightMode(COLOR_BAR));
set_icon_backcolor(speaker);
//////////////////////////////////////////////////////////////////////
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_TEXT_LIST));
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_SEL,get_color_NightMode(COLOR_TEXT_LIST));
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_TEXT_LIST));
LISTBOX_SetTextColor(ListItem,LISTBOX_CI_DISABLED,get_color_NightMode(COLOR_ListItem_DISABLE));
LISTBOX_SetBackColor(ListItem,LISTBOX_CI_UNSEL,get_color_NightMode(COLOR_ListItem_UNSEL));
LISTBOX_SetBackColor(ListItem,LISTBOX_CI_SEL,get_color_NightMode(COLOR_ListItem_UNFORCE));
LISTBOX_SetBackColor(ListItem,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_SELECTED));
LISTBOX_SetBackColor(ListItem,LISTBOX_CI_DISABLED,get_color_NightMode(COLOR_ListItem_UNSEL));
TEXT_SetTextColor(ScrollUpWin, get_color_NightMode(COLOR_TEXT_LIST));
TEXT_SetTextColor(ScrollDownWin, get_color_NightMode(COLOR_TEXT_LIST));
switch (menu_page){
case MENU_SoundSettings:
SoundSettings_page(0);
break;
case MENU_DecoySettings:
DecoySettings_page();
break;
case MENU_DisplaySettings:
DisplaySettings_page(0);
break;
case MENU_SyncSettings:
SyncSettings_page(0);
break;
case MENU_AddDoggs:
TEXT_SetTextColor(TextWin[0],get_color_NightMode(COLOR_TEXT_LIST));
break;
case MENU_EditDoggName:
TEXT_SetTextColor(TextWin[0],get_color_NightMode(COLOR_TEXT_LIST));
EDIT_SetTextColor(EditWin1,EDIT_CI_ENABLED,get_color_NightMode(COLOR_TEXT_LIST));
EDIT_SetBkColor(EditWin1,EDIT_CI_ENABLED,get_color_NightMode(COLOR_EditBox_Back));
break;
}
}
void nightMode(void)
{
if(main_coff.night_mode==0)
{
main_coff.night_mode=1;
}
else
{
main_coff.night_mode=0;
}
saveCoff_in_Flash();
nightmode_changeMode();
}
void change_status(void)
{
u8 TxBuf[4];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|UART_COMMAND_WRITE;
TxBuf[BUFFER_LENGTH]=2;//2个参数
TxBuf[BUFFER_PARAM1]=0x05;
TxBuf[BUFFER_PARAM1+1]=current_dogg->setting;
sendtx(dogg[speaker].ID,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
void change_decoy(void)
{
u16 id;
u8 TxBuf[BUFFER_PARAM1+6+1];
if(decoy_linked)
{
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|UART_COMMAND_DECOY;
TxBuf[BUFFER_LENGTH]=1;//6个参数
TxBuf[BUFFER_PARAM1] = 0x80|0x20 | decoy_speed;
id= (decoy_sn[4]<<8) |decoy_sn[5] ;
sendtx(id,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
}
void setup_hot_key(u8 x)
{
switch (x)
{
case 0:
main_coff.hotkey[0]=HotKey_NightMode;
ListIndex[MENU_Hotx]=HotKey_NightMode;
ListIndex[MENU_HotKeySettings]=0;
break;
case 1:
main_coff.hotkey[1]=HotKey_AllOff;
ListIndex[MENU_Hotx]=HotKey_AllOff;
ListIndex[MENU_HotKeySettings]=1;
break;
case 2:
main_coff.hotkey[2]=HotKey_SettingsMenu;
ListIndex[MENU_Hotx]=HotKey_SettingsMenu;
ListIndex[MENU_HotKeySettings]=2;
break;
case 3:
main_coff.hotkey[3]=HotKey_MainMenu;
ListIndex[MENU_Hotx]=HotKey_MainMenu;
ListIndex[MENU_HotKeySettings]=3;
break;
}
BUTTON_SetText(BtnHotkey[x],hotkey_string(ListIndex[MENU_Hotx]));
saveCoff_in_Flash();
WM_HideWindow(Logo_window);
WM_HideSubWin();
WM_ShowWindow(MainTitle);
WM_ShowWindow(ListItem);
WM_SetFocus(ListItem);
hotkeySetting_page();
}
u8 hot_key(u8 x)
{
u8 TxBuf[4];
u8 tmp = main_coff.hotkey[x];
if(!WM_IsVisible(BtnHotkey [x]))return 0xff;
if(keyboard_en)
{
GUI_EndDialog(hKeyboard,0);
keyboard_en=0;
}
reading_mode_option=0;
switch(tmp)
{
case HotKey_PlaySound: //Hotkey Activate Sound Speaker1
WM_HideWindow(Logo_window);
PlaySounds_page();
ListIndex[MENU_Sounds]=0;
LISTBOX_SetSel(ListItem,0);
break;
case HotKey_AllOff: //Hotkey All Off();
toAll=1;
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote|UART_COMMAND_WRITE;
TxBuf[BUFFER_LENGTH]=2;
TxBuf[BUFFER_PARAM1]=0;
TxBuf[BUFFER_PARAM1+1]=DOGG_ALL_OFF;
#ifdef DECOY_ALL_OFF
if(decoy_linked)
{
sendtx(0xffff,TxBuf,5,UART_COMMAND_ACK);
}
#endif
for(tmp =0;tmp < Doggs_List_MAX;tmp++){
if(dogg[tmp].doggtype!=0xFF)
{
sendtx(dogg[tmp].ID,TxBuf,5,UART_COMMAND_ACK);
}
}
//system_set_powersave(0);
toAll=0;
break;
case HotKey_NightMode: //Hotkey Night Mode
nightMode();
break;
case HotKey_SettingsMenu:
Settings_page(1);
ListIndex[menu_page]=0;
break;
case HotKey_MainMenu:
menu_key();
break;
}
return 0;
}
void keyboard_popup(void)
{
WM_HWIN hwin;
hKeyboard=CreateKeyboard();
WM_SetStayOnTop(hKeyboard, 1);
WM_SetFocus(EditWin1);
keyboard_en=1;
hwin = WM_GetDialogItem(hKeyboard, GUI_ID_USER+keyboard_en);
BUTTON_SetPressed(hwin,1);
}
void keyboard_LeftRight_key(u8 key)
{
WM_HWIN hwin;
hwin = WM_GetDialogItem(hKeyboard, GUI_ID_USER+keyboard_en);
BUTTON_SetPressed(hwin,0);
if(key == KEY_RIGHT)
{
switch(keyboard_en)
{
case 10:
keyboard_en=1;
break;
case 20:
keyboard_en=11;
break;
case 30:
keyboard_en=21;
break;
case 39:
keyboard_en=31;
break;
default:
keyboard_en++;
break;
}
}
else if(key == KEY_LEFT)
{
switch(keyboard_en)
{
case 1:
keyboard_en=10;
break;
case 11:
keyboard_en=20;
break;
case 21:
keyboard_en=30;
break;
case 31:
keyboard_en=39;
break;
default:
keyboard_en--;
break;
}
}
hwin = WM_GetDialogItem(hKeyboard, GUI_ID_USER+keyboard_en);
BUTTON_SetPressed(hwin,1);
}
void keyboard_up_key(void)
{
WM_HWIN hwin;
hwin = WM_GetDialogItem(hKeyboard, GUI_ID_USER+keyboard_en);
BUTTON_SetPressed(hwin,0);
if(keyboard_en>10)
{
keyboard_en-=10;
}
else
{
keyboard_en+=30;
if(keyboard_en==40)keyboard_en=39;
}
hwin = WM_GetDialogItem(hKeyboard, GUI_ID_USER+keyboard_en);
BUTTON_SetPressed(hwin,1);
}
void keyboard_down_key(void)
{
WM_HWIN hwin;
hwin = WM_GetDialogItem(hKeyboard, GUI_ID_USER+keyboard_en);
BUTTON_SetPressed(hwin,0);
if(keyboard_en<31)
{
keyboard_en+=10;
if(keyboard_en==40)keyboard_en=39;
}
else
{
keyboard_en-=30;
}
hwin = WM_GetDialogItem(hKeyboard, GUI_ID_USER+keyboard_en);
BUTTON_SetPressed(hwin,1);
}
u8 keyboard_enter_key(u8 sizeMax)
{
char chr[2];
WM_HWIN hwin;
u8 pos;
pos= EDIT_GetCursorCharPos(EditWin1);
switch(keyboard_en)
{
default:
hwin = WM_GetDialogItem(hKeyboard, GUI_ID_USER+keyboard_en);
BUTTON_GetText(hwin,chr,2);
if(pos >= sizeMax)return 0;
text_keyboard[pos] = *chr;
text_keyboard[++pos]=0;
EDIT_SetText(EditWin1, text_keyboard);
EDIT_SetCursorAtChar(EditWin1,pos);
return *chr;
case 30://backspace
if(pos>0)text_keyboard[--pos]=0;
EDIT_SetText(EditWin1, text_keyboard);
EDIT_SetCursorAtChar(EditWin1,pos);
return 8;
case 39://enter
GUI_EndDialog(hKeyboard,0);
keyboard_en=0;
WM_SetFocus(ListItem);
return 0x0d;
}
}
u8 up_key(void)
{
if(menu_page==MENU_home)
{
WM_SetFocus(ListItem_doggs);
if(ListIndex[MENU_home]>0)
{
ListIndex[MENU_home]-=1;
}
LISTBOX_SetSel(ListItem_doggs,ListIndex[MENU_home]);
set_icon_backcolor(ListIndex[MENU_home]);
}
else if(menu_page==MENU_GoPage)
{
LISTBOX_DecSel(ListItem);
}
else if(menu_page==MENU_MainMenu && MainMenuHideItem)
{
if(LISTBOX_GetSel(ListItem)==2){
LISTBOX_SetSel(ListItem,(LISTBOX_GetNumItems(ListItem)-1));
}else{
LISTBOX_DecSel(ListItem);
}
ListIndex[menu_page]= LISTBOX_GetSel(ListItem);
}
else if(keyboard_en)
{
keyboard_up_key();
}
else if(list2_funtion != 0)//play子菜单
{
WM_SetFocus(ListItem2);
LISTBOX_DecSel(ListItem2);
}
else if(menu_page==MENU_CreatHunt2)
{
if(tmp_expert_idx)
{
LISTBOX_SetBkColor(ListItem3,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_SELECTED));
mode_EP_navigation=0;
if(btn_horz==1)
{
BUTTON_SetPressed(Btnexp[0],0);
BUTTON_SetPressed(Btnexp[1],0);
BUTTON_SetPressed(Btnexp[2],0);
}
if(selected_itemexpert>0)selected_itemexpert--;
else
selected_itemexpert=tmp_expert_idx-1;
LISTBOX_SetSel(ListItem3,selected_itemexpert);
}
}
else if(menu_page==MENU_CreatHuntName)
{
WM_SetFocus(ListItem);
if(ListIndex[menu_page]==0)
{
ListIndex[menu_page]=5;
}
else
{
ListIndex[menu_page]=0;
}
LISTBOX_SetSel(ListItem,ListIndex[menu_page]);
}
else//普通菜单
{
WM_SetFocus(ListItem);
#ifdef Sroll_UP2DoggSelector
if(LISTBOX_GetSel(ListItem) == 0 && ActiveDoggsNumber > 1)
{
menu_page=MENU_home;
WM_SetFocus(ListItem_doggs);
ListIndex[MENU_home]=ActiveDoggsNumber-1;
LISTBOX_SetSel(ListItem_doggs,ListIndex[MENU_home]);
set_icon_backcolor(ListIndex[MENU_home]);
}
else
#endif
{
if(LISTBOX_GetSel(ListItem) == 0)
{
LISTBOX_SetSel(ListItem,LISTBOX_GetNumItems(ListItem));
}
else
{
LISTBOX_DecSel(ListItem);
}
ListIndex[menu_page] = LISTBOX_GetSel(ListItem);
}
}
return 0;
}
u8 down_key(void)
{
if(menu_page==MENU_home)
{
WM_SetFocus(ListItem_doggs);
if(ListIndex[MENU_home] < (ActiveDoggsNumber-1))
{
ListIndex[MENU_home]+=1;
}
else
{
WM_SetFocus(ListItem);
menu_page=current_menu;
ListIndex[menu_page]=0;
LISTBOX_SetSel(ListItem,ListIndex[menu_page]);
}
LISTBOX_SetSel(ListItem_doggs,ListIndex[MENU_home]);
set_icon_backcolor(ListIndex[MENU_home]);
}
else if(menu_page==MENU_GoPage)
{
LISTBOX_IncSel(ListItem);
}
else if(menu_page==MENU_MainMenu && MainMenuHideItem)
{
if(LISTBOX_GetSel(ListItem)==(LISTBOX_GetNumItems(ListItem)-1)){
LISTBOX_SetSel(ListItem,2);
}
else{
LISTBOX_IncSel(ListItem);
}
ListIndex[menu_page]= LISTBOX_GetSel(ListItem);
}
else if(keyboard_en)
{
keyboard_down_key();
}
else if(list2_funtion != 0)
{
WM_SetFocus(ListItem2);
if(LISTBOX_GetSel(ListItem2) == LISTBOX_GetNumItems(ListItem2))
LISTBOX_SetSel(ListItem2,0);
else
LISTBOX_IncSel(ListItem2);
}
else if(menu_page==MENU_CreatHunt2)
{
if(tmp_expert_idx)
{
LISTBOX_SetBkColor(ListItem3,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_SELECTED));
mode_EP_navigation=0;
if(btn_horz==1)
{
BUTTON_SetPressed(Btnexp[0],0);
BUTTON_SetPressed(Btnexp[1],0);
BUTTON_SetPressed(Btnexp[2],0);
}
if(selected_itemexpert<tmp_expert_idx)
selected_itemexpert++;
else
selected_itemexpert=0;
LISTBOX_SetSel(ListItem3,selected_itemexpert);
}
}
else if(menu_page==MENU_CreatHuntName)
{
WM_SetFocus(ListItem);
ListIndex[menu_page]= LISTBOX_GetSel(ListItem);
if(ListIndex[menu_page]==0)
{
ListIndex[menu_page]=5;
}
else
{
ListIndex[menu_page]=0;
}
LISTBOX_SetSel(ListItem,ListIndex[menu_page]);
}
else
{
WM_SetFocus(ListItem);
if(LISTBOX_GetSel(ListItem) == (LISTBOX_GetNumItems(ListItem)-1))
LISTBOX_SetSel(ListItem,0);
else
LISTBOX_IncSel(ListItem);
ListIndex[menu_page]= LISTBOX_GetSel(ListItem);
}
return 0;
}
u8 adj_key(u8 key)
{
u8 tmp,tmp2;
s8 vol;
char szBuff[4];
u8 TxBuf[4];
char intsBuff[32];
u32 color_btn,color_btnS;
color_btn= get_color_NightMode(COLOR_BTN_UNSEL);
color_btnS= get_color_NightMode(COLOR_BTN_SELECTED);
switch(menu_page)
{
default:
break;
case MENU_GoPage:
break;
case MENU_CreatHunt2:
if(btn_horz)
{
LISTBOX_SetBkColor(ListItem3,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_UNSEL));
mode_EP_navigation=1;
BUTTON_SetPressed(Btnexp[btn_horz-1],0);
if(key == KEY_RIGHT)
{
if(btn_horz<3)
{
btn_horz++;
}
else
{
btn_horz=btn_low;
}
}
else if(key == KEY_LEFT)
{
if(btn_horz>btn_low)
{
btn_horz--;
}
else
{
btn_horz=3;
}
}
BUTTON_SetPressed(Btnexp[btn_horz-1],1);
}
break;
case MENU_EditDoggName:
if(keyboard_en){
keyboard_LeftRight_key(key);
}else if(LISTBOX_GetSel(ListItem) ==0){
tmp = EDIT_GetCursorCharPos(EditWin1);
if(key == KEY_LEFT){
if(tmp)tmp--;
}
else if(key == KEY_RIGHT){
tmp++;
tmp2 = EDIT_GetNumChars(EditWin1);
if(tmp >tmp2)tmp = tmp2;
}
EDIT_SetCursorAtChar(EditWin1,tmp);
}
break;
case MENU_CreatHuntName:
if(keyboard_en){
keyboard_LeftRight_key(key);
}
break;
case MENU_home://调音量
if(ListIndex[MENU_home]==0)
{
if(key == KEY_RIGHT)
{
if(key_repeat_count ==0 || ((dogg[0].main_volume%5) !=0))
dogg[0].main_volume+=1;
else
dogg[0].main_volume+=5;
if(dogg[0].main_volume>100) dogg[0].main_volume=100;
}
else if(key == KEY_LEFT)
{
if(key_repeat_count ==0 || ((dogg[0].main_volume%5) !=0))
{
if(dogg[0].main_volume>0)dogg[0].main_volume-=1;
}
else if(dogg[0].main_volume >=5)
{
dogg[0].main_volume-=5;
}
}
sprintf(szBuff,"%d",dogg[0].main_volume);
TEXT_SetText(doggsWin[0][6],szBuff);
TxBuf[BUFFER_COMMAND] = COMMAND_FromRemote |UART_COMMAND_WRITE;
TxBuf[BUFFER_PARAM1+1]=dogg[0].main_volume;
}
else if(ListIndex[MENU_home]==1)
{
if(key == KEY_RIGHT)
{
if(key_repeat_count ==0 || ((dogg[1].main_volume%5) !=0))
dogg[1].main_volume+=1;
else
dogg[1].main_volume+=5;
if(dogg[1].main_volume>100) dogg[1].main_volume=100;
}
else if(key == KEY_LEFT)
{
if(key_repeat_count ==0 || ((dogg[1].main_volume%5) !=0))
{
if(dogg[1].main_volume>0)dogg[1].main_volume-=1;
}
else if(dogg[1].main_volume >=5)
{
dogg[1].main_volume-=5;
}
}
sprintf(szBuff,"%d",dogg[1].main_volume);
TEXT_SetText(doggsWin[1][6],szBuff);
TxBuf[BUFFER_COMMAND]=COMMAND_FromRemote |UART_COMMAND_WRITE;
TxBuf[BUFFER_PARAM1+1]=dogg[1].main_volume;
}
else if(ListIndex[MENU_home]==2)
{
if(key == KEY_RIGHT)
{
if(key_repeat_count ==0 || ((dogg[2].main_volume%5) !=0))
dogg[2].main_volume+=1;
else
dogg[2].main_volume+=5;
if(dogg[2].main_volume>100) dogg[2].main_volume=100;
}
else if(key == KEY_LEFT)
{
if(key_repeat_count ==0 || ((dogg[2].main_volume%5) !=0))
{
if(dogg[2].main_volume>0)dogg[2].main_volume-=1;
}
else if(dogg[2].main_volume >=5)
{
dogg[2].main_volume-=5;
}
}
sprintf(szBuff,"%d",dogg[2].main_volume);
TEXT_SetText(doggsWin[2][6],szBuff);
TxBuf[BUFFER_COMMAND]=COMMAND_FromRemote |UART_COMMAND_WRITE;
TxBuf[BUFFER_PARAM1+1]=dogg[2].main_volume;
}
TxBuf[BUFFER_LENGTH]=2;
TxBuf[BUFFER_PARAM1]=0x01;
tmp=id_to_spk(current_dogg->ID);
current_dogg = &dogg[ListIndex[MENU_home]];
sendtx(dogg[speaker].ID,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
current_dogg = &dogg[tmp];
return KEY_EVENT_REPEAT;
case MENU_SoundSettings:
if(ListIndex[MENU_SoundSettings]==SoundSetting_SpkMode)//speaker source
{
if(key == KEY_RIGHT)
{
BUTTON_SetBkColor(BtnWin[1],BUTTON_CI_UNPRESSED,color_btnS);
BUTTON_SetBkColor(BtnWin[0],BUTTON_CI_UNPRESSED,color_btn);
tmp_adj[0] = 1;
}
else if(key == KEY_LEFT)
{
BUTTON_SetBkColor(BtnWin[0],BUTTON_CI_UNPRESSED,color_btnS);
BUTTON_SetBkColor(BtnWin[1],BUTTON_CI_UNPRESSED,color_btn);
tmp_adj[0] = 0;
}
}
else if(ListIndex[MENU_SoundSettings]==SoundSetting_EQ)//EQ
{
#if 1
tmp = tmp_adj[1];
if(key == KEY_LEFT){
if(tmp ==0)
tmp=2;
else
tmp--;
}else if(key == KEY_RIGHT){
tmp ++;
}
if(tmp > 2)tmp = 0;
tmp_adj[1]= tmp;
get_EQ_type_string(tmp,intsBuff);
TEXT_SetText(TextWin[0],intsBuff);
#endif
}
else if(ListIndex[MENU_SoundSettings]==SoundSetting_Loop)//repeat
{
if(key == KEY_LEFT)
{
BUTTON_SetBkColor(BtnWin[3],BUTTON_CI_UNPRESSED,color_btn);
BUTTON_SetBkColor(BtnWin[2],BUTTON_CI_UNPRESSED,color_btnS);
tmp_adj[2] = 1;
}
else if(key == KEY_RIGHT)
{
BUTTON_SetBkColor(BtnWin[2],BUTTON_CI_UNPRESSED,color_btn);
BUTTON_SetBkColor(BtnWin[3],BUTTON_CI_UNPRESSED,color_btnS);
tmp_adj[2] = 0;
}
}
else if(ListIndex[MENU_SoundSettings]==SoundSetting_Bass)
{
if(key == KEY_RIGHT)
{
SLIDER_Inc(WIN_SLIDER_BASS);
}
else if(key == KEY_LEFT)
{
SLIDER_Dec(WIN_SLIDER_BASS);
}
vol = SLIDER_GetValue(WIN_SLIDER_BASS);
if(current_dogg->SubwooferVol != vol){
current_dogg->SubwooferVol = vol;
if(vol >0)
sprintf(intsBuff,"+%d",vol);
else
sprintf(intsBuff,"%d",vol);
TEXT_SetText(TextWin[1],intsBuff);
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote |UART_COMMAND_WRITE;
TxBuf[BUFFER_LENGTH]=2;//2个参数
TxBuf[BUFFER_PARAM1]=0x03;
TxBuf[BUFFER_PARAM1+1]=current_dogg->SubwooferVol;
sendtx(dogg[speaker].ID,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
return KEY_EVENT_REPEAT;
}
}
else if(ListIndex[MENU_SoundSettings]==SoundSetting_Treble)
{
if(key == KEY_RIGHT)
{
SLIDER_Inc(WIN_SLIDER_TREBLE);
}
else if(key == KEY_LEFT)
{
SLIDER_Dec(WIN_SLIDER_TREBLE);
}
vol = SLIDER_GetValue(WIN_SLIDER_TREBLE);
if(current_dogg->TweeterVol != vol){
current_dogg->TweeterVol = vol;
if(vol >0)
sprintf(intsBuff,"+%d",vol);
else
sprintf(intsBuff,"%d",vol);
TEXT_SetText(TextWin[2],intsBuff);
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote |UART_COMMAND_WRITE;
TxBuf[BUFFER_LENGTH]=2;//2个参数
TxBuf[BUFFER_PARAM1]=0x02;
TxBuf[BUFFER_PARAM1+1]=current_dogg->TweeterVol;
sendtx(dogg[speaker].ID,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
return KEY_EVENT_REPEAT;
}
#if 0//ndef SoundSettingEnterKey
tmp = (tmp_adj[1])& STATE_EQ_MASK;
if(tmp_adj[0]) tmp |= STATE_BT_MASK;
if(tmp_adj[2]) tmp |= STATE_LOOP_MASK;
if(current_dogg->setting != tmp){
current_dogg->setting = tmp;
change_status();
}
#endif
}
break;
case MENU_DecoySettings:
#if 0
if(ListIndex[MENU_DecoySettings]==0)
{
if(key == KEY_RIGHT)
{
tmp_adj[0]=1;
BUTTON_SetBkColor(BtnWin[6],BUTTON_CI_UNPRESSED,color_btn);
BUTTON_SetBkColor(BtnWin[7],BUTTON_CI_UNPRESSED,color_btnS);
}
else if(key == KEY_LEFT)
{
tmp_adj[0]=0;
BUTTON_SetBkColor(BtnWin[7],BUTTON_CI_UNPRESSED,color_btn);
BUTTON_SetBkColor(BtnWin[6],BUTTON_CI_UNPRESSED,color_btnS);
}
}
else if(ListIndex[MENU_DecoySettings]==1)
#endif
{
if(key == KEY_RIGHT)
{
if(++tmp_adj[1]>5)tmp_adj[1]=5;
}
else if(key == KEY_LEFT)
{
if(tmp_adj[1])tmp_adj[1]--;
}
for(tmp=0;tmp<6;tmp++)
{
BUTTON_SetBkColor(BtnWin[tmp],BUTTON_CI_UNPRESSED,color_btn);
}
BUTTON_SetBkColor(BtnWin[tmp_adj[1]],BUTTON_CI_UNPRESSED,color_btnS);
if(decoy_speed != tmp_adj[1])
{
decoy_speed = tmp_adj[1];
//saveCoff_in_Flash();
change_decoy();
}
}
break;
case MENU_DisplaySettings:
switch(ListIndex[MENU_DisplaySettings])
{
case DisplaySetting_NightMode://night
if(key == KEY_RIGHT)
{
tmp_adj[0]=1;
BUTTON_SetBkColor(BtnWin[0],BUTTON_CI_UNPRESSED,color_btn);
BUTTON_SetBkColor(BtnWin[1],BUTTON_CI_UNPRESSED,color_btnS);
}
else if(key == KEY_LEFT)
{
tmp_adj[0]=0;
BUTTON_SetBkColor(BtnWin[0],BUTTON_CI_UNPRESSED,color_btnS);
BUTTON_SetBkColor(BtnWin[1],BUTTON_CI_UNPRESSED,color_btn);
}
break;
#ifdef FONT_SIZE
case DisplaySetting_FontSize:
tmp = tmp_adj[1];
BUTTON_SetBkColor(BtnWin[2+tmp],BUTTON_CI_UNPRESSED,color_btn);
if(key == KEY_RIGHT)
{
if(++tmp >2)tmp =2;
}
else if(key == KEY_LEFT)
{
if(tmp)tmp--;
}
tmp_adj[1] =tmp;
BUTTON_SetBkColor(BtnWin[2+tmp],BUTTON_CI_UNPRESSED,color_btnS);
break;
#endif
case DisplaySetting_TimerControl:
tmp = tmp_adj[2];
BUTTON_SetBkColor(BtnWin[5+tmp],BUTTON_CI_UNPRESSED,color_btn);
if(key == KEY_RIGHT)
{
if(++tmp >2)tmp =2;
}
else if(key == KEY_LEFT)
{
if(tmp)tmp--;
}
tmp_adj[2] =tmp;
BUTTON_SetBkColor(BtnWin[5+tmp],BUTTON_CI_UNPRESSED,color_btnS);
break;
case DisplaySetting_Brightness://brightness
if(key == KEY_RIGHT)
{
if(key_repeat_count)
{
brightness++;
}
else
{
brightness+=5;
brightness = brightness-(brightness % 5);
}
if(brightness>100)brightness=100;
}
else if(key == KEY_LEFT)
{
if(brightness)brightness--;
if(key_repeat_count==0)
{
brightness =brightness-(brightness % 5);
}
}
set_brightness((brightness !=0) ? brightness : 1);
SCROLLBAR_SetValue(ScrollWin,brightness);
//saveCoff_in_Flash();
return KEY_EVENT_REPEAT;
}
break;
}
return 0;
}
u8 get_skip_index(u8 index)
{
u8 tmp = index;
if(index > Folder_Hunts)tmp++;
if(index > Folder_Favorite)tmp++;
//if(index > Folder_PlayList)tmp++;
return tmp;
}
u8 enter_key(void)
{
u8 count;
s8 dy;
u8 select,tmp;
u16 tmp16;
DOGG_registed * p_reg;
DOGG_Type * p_dogg;
char intsBuff[Max_stringlen];
select = LISTBOX_GetSel(ListItem);
switch (menu_page)
{
case MENU_home:
current_dogg = &dogg[ListIndex[MENU_home]];
WM_SetWindowPos(doggSelectIcon,2, 41+(ListIndex[MENU_home]*20), 20, 19);
menu_key();
break;
case MENU_GoPage:
if(WM_IsVisible(ListItem)){
if(LISTBOX_GetSel(ListItem)==0){
searching_mode = SearchMode_startup;
task1_state = TaskSTATE_CheckDogg;
}else {
GUI_EndDialog(first_window, 0);
main_window = CreateWindow();//主窗体
speaker = 0;
current_dogg = &dogg[0];
timer_count_start=1;
MyDoggs_page(1);
searching_mode = 0;
task1_state = TaskSTATE_NORMAL;
}
}
break;
case MENU_SyncSettings:
//if(LISTBOX_GetNumItems(ListItem) < 2)return 0;
WM_ShowWindow(TextWin[1]);
WM_ShowWindow(ProgWin);
PROGBAR_SetValue(ProgWin, 0);
task1_state = TaskSTATE_MenuSYNC_start;
break;
case MENU_MainMenu://菜单首页
switch(select)
{
case 0:
if(ActiveDoggsNumber != 0)
{
Sounds_page();
ListIndex[menu_page]=0;
LISTBOX_SetSel(ListItem,0);
}
else
{
}
break;
case 1:
current_dogg = &dogg[speaker];
if(ActiveDoggsNumber != 0)
{
ExpertHunts_page();
}
else
{
}
break;
case 2:
Settings_page(1);
break;
case 3:
SyncSettings_page(1);
break;
}
break;
case MENU_ExpertHunts:
if(select == (LISTBOX_GetNumItems(ListItem)-1) && (!reading_mode_option))//最后一项
{
CreateHunt_page();
}
else {
select = LISTBOX_GetSel(ListItem);
if(list2_funtion ==0)
{
if(select < hunt_filesNumber){
ListItem2_popup(2);
}
else{
ListItem2_popup(3);
LISTBOX_SetString(ListItem2,"Delect",2);
}
LISTBOX_SetString(ListItem2,"Play",0);
LISTBOX_SetString(ListItem2,"Add Favorite",1);
LISTBOX_SetSel(ListItem2,0);
list2_funtion =1;
playing = 0;
}else{
hunt_option_list(select);
}
}
break;
case MENU_CreatHuntName:
if(!keyboard_en)
keyboard_popup();
else if(keyboard_enter_key(20) == 0x0d)//enter
{
tmp = strlen(text_keyboard);
if(tmp >0)
{
scroll_pos=0;
CreateHunt_page_two();
}
}
break;
case MENU_CreatHunt2:
if((!mode_EP_navigation))
{
if(tmp_expert_idx)
{
WM_HideWindow(Btnexp[0]);
WM_HideWindow(Btnexp[1]);
WM_HideWindow(Btnexp[2]);
sub_expert_menu=1;
hunt_option_list(list2_funtion);
}
else if(btn_horz)
{
WM_ShowWindow(Btnexp[0]);
WM_ShowWindow(Btnexp[1]);
WM_ShowWindow(Btnexp[2]);
}
}
else{
if(btn_horz==1)
{
if(get_tree_size(current_dogg->tree.DirTree)==0xffff)break;
WM_HideWindow(Btnexp[0]);
WM_HideWindow(Btnexp[1]);
WM_HideWindow(Btnexp[2]);
menu_page=MENU_CardFolder;
sub_expert_menu=1;
TEXT_SetText(MainTitle,"All Sounds");
ListItem_clear_item();
//WM_HideSubWin();
WM_HideWindow(ListItem3);
WM_HideWindow(TextWin[2]);
WM_SetFocus(ListItem);
tmp16= *(__IO u16 *)(p_dogg->tree.DirTree+FLASH_DATA_STARTADDR);
list_draw_childs(current_dogg->tree.DirTree,tmp16);
LISTBOX_SetSel(ListItem,0);
global_node =tmp16;
folderdeep = 0;
current_path[0].node = tmp16;
strcpy(current_path[0].name,"/");
}
else if (btn_horz==2)
{
if(tmp_expert_idx)
{
if(playing_expert)
{
playing_expert=0;
write_register(current_dogg->ID,4,3);
sound_info.state = SOUND_PAUSED;
BUTTON_SetText(Btnexp[1],"Play");
}
else
{
playing_expert=1;
TEXT_SetText(TopStatusWin[5],"00:00");
sound_info.current_time=0;
sound_info.duration_time=0;
send_FileDirNode_cmd(current_dogg->ID,UART_COMMAND_PlayFile,tmp_expert[playing_expert-1]);
sound_info.state = SOUND_PLAYING;
timer_count_start=1;
BUTTON_SetText(Btnexp[1],"Stop");
}
}
}
else if (btn_horz==3)
{
EDIT_GetText(EditWin1,intsBuff,Max_stringlen);
flag_ack=0;
Remote_create_ExpH(current_dogg->ID,intsBuff,tmp_expert,tmp_expert_idx);
if(flag_ack)
{
TEXT_SetText(genBtn,"Successful");
LISTBOX_AddString(listExperts,intsBuff);
for(tmp=0;tmp < EpertHuntName_MAX;tmp++)intsBuff[tmp]=0;
SPI_FLASH_SectorErase((current_dogg->tree.DirTree)+EXPT_HUNTS_OFFST);
select =LISTBOX_GetNumItems(listExperts);
tmp16=0;
SPI_FLASH_Write1HalfWord(((current_dogg->tree.DirTree)+EXPT_HUNTS_OFFST), tmp);
tmp16=2;
for(count = 0; count < select ; count++)
{
LISTBOX_GetItemText(listExperts,count,intsBuff,EpertHuntName_MAX);
SPI_FLASH_BufferWrite((u8 *)&intsBuff[0],((current_dogg->tree.DirTree)+EXPT_HUNTS_OFFST+tmp16), EpertHuntName_MAX);
tmp16 += EpertHuntName_MAX;
}
WM_HideSubWin();
ExpertHunts_page();
}
}
}
break;
case MENU_Setting:
switch(select)
{
case SettingPageSelect_SoundSetting:
SoundSettings_page(1);
break;
#ifdef DECOY_SETTING
case SettingPageSelect_DecoySetting:
DecoySettings_page();
break;
#endif
case SettingPageSelect_DisplaySetting:
DisplaySettings_page(1);
break;
case SettingPageSelect_DeviceInfo:
DeviceInfo_page();
break;
case SettingPageSelect_HotkeySetting:
SelectHotKey_page();
break;
case SettingPageSelect_SyncSetting:
SyncSettings_page(1);
break;
case SettingPageSelect_Mydoggs:
MyDoggs_page(1);
break;
default:
Settings_page(0);
break;
}
break;
case MENU_SoundSettings:
if(select==SoundSetting_EQ){
if(list2_funtion) {
list2_funtion = 0;
if(current_dogg->setting != tmp){
current_dogg->setting = tmp;
change_status();
}
WM_HideWindow(ListItem2);
tmp = LISTBOX_GetSel(ListItem2);
tmp_adj[1] = tmp;
get_EQ_type_string(tmp,intsBuff);
TEXT_SetText(TextWin[0],intsBuff);
WM_SetFocus(ListItem);
} else {
ListItem2_popup(3);
get_EQ_type_string(0,intsBuff);
LISTBOX_SetString(ListItem2,intsBuff,0);
get_EQ_type_string(1,intsBuff);
LISTBOX_SetString(ListItem2,intsBuff,1);
get_EQ_type_string(2,intsBuff);
LISTBOX_SetString(ListItem2,intsBuff,2);
LISTBOX_SetSel(ListItem2,tmp_adj[1]);
WM_ShowWindow(ListItem2);
list2_funtion=1;
break;
}
}
tmp = (tmp_adj[1])& STATE_EQ_MASK;
if(tmp_adj[0]) tmp |= STATE_BT_MASK;
if(tmp_adj[2]) tmp |= STATE_LOOP_MASK;
if(current_dogg->setting != tmp)
{
current_dogg->setting = tmp;
change_status();
}
break;
case MENU_DecoySettings:
if(tmp_adj[0] != decoy_link)
{
decoy_link= tmp_adj[0];
change_decoy();
}
break;
case MENU_DisplaySettings:
if(tmp_adj[2]==2)
{
sec=min=0;
TEXT_SetText(TopStatusWin[6],"0:00");
}
else if(timer_enable != tmp_adj[2])
{
timer_enable = tmp_adj[2];
//saveCoff_in_Flash();
}
if(main_coff.font_size != tmp_adj[1]){
dy = (tmp_adj[1]-main_coff.font_size)*4;
main_coff.font_size = tmp_adj[1];
saveCoff_in_Flash();
resize_allWindows();
TEXT_SetFont(MainTitle, GUI_FONT_32S);
for(tmp=0;tmp<8;tmp++){
WM_MoveWindow(BtnWin[tmp], 0, dy);
}
WM_MoveWindow(ScrollWin, 0, dy);
}
if(timer_enable != tmp_adj[2])
{
//saveCoff_in_Flash();
timer_enable = tmp_adj[2];
}
if(main_coff.night_mode != tmp_adj[0])
{
main_coff.night_mode = tmp_adj[0];
saveCoff_in_Flash();
nightmode_changeMode();
break;
}
break;
case MENU_DeviceInfo:
Settings_page(0);
LISTBOX_SetSel(ListItem,ListIndex[menu_page]);
break;
case MENU_HotKeySettings:
hotkeySetting_page();
break;
case MENU_Hotx:
Select_Hotkey();
SelectHotKey_page();
LISTBOX_SetSel(ListItem,ListIndex[menu_page]);
saveCoff_in_Flash();
break;
///////////////////////////////////////////////
case MENU_Sounds:
if(select == 0)//all sound
{
menu_page=MENU_CardFolder;
TEXT_SetText(MainTitle,"All Sounds");
ListItem_clear_item();
p_dogg = &dogg[LISTBOX_GetSel(ListItem_doggs)];
btn_horz=0;
if(get_tree_size(p_dogg->tree.DirTree)==0xffff)break;
tmp16= *(__IO u16 *)(p_dogg->tree.DirTree+FLASH_DATA_STARTADDR);
list_draw_childs(current_dogg->tree.DirTree,tmp16);
LISTBOX_SetSel(ListItem,0);
global_node = tmp16;
folderdeep = 0;
current_path[0].node = tmp16;
strcpy(current_path[0].name,"/");
}
else if(select == 1)//favorite
{
FavoriteSounds_page();
ListIndex[MENU_FavorriteSounds]=0;
LISTBOX_SetSel(ListItem,0);
}
break;
case MENU_CardFolder:
if(list2_funtion){
select = LISTBOX_GetSel(ListItem2);
folder_option_list(select);
}else{
enter_DirList();
}
break;
case MENU_FavorriteSounds:
if(LISTBOX_GetNumItems(ListItem)==0)return 0;
if(list2_funtion == 0){
ListItem2_popup(2);
LISTBOX_SetString(ListItem2,"Play",0);
if(sub_expert_menu || mode_EP_navigation)
LISTBOX_SetString(ListItem2,"Add to Expert Hunt",1);
else
LISTBOX_SetString(ListItem2,"Delete",1);
list2_funtion = 1;
}else {
select = LISTBOX_GetSel(ListItem2);
if(select == 0)
favorate_option_list(0);
else if(sub_expert_menu || mode_EP_navigation)
favorate_option_list(1);
else
favorate_option_list(2);
}
break;
case MENU_MyDoggs:
if(select == 0)//Add new
{
DoggsSelection_page();
}else if((select+1) == LISTBOX_GetNumItems(ListItem)){//Submit
Settings_page(0);
LISTBOX_SetSel(ListItem,ListIndex[MENU_Setting]);
}else if(list2_funtion) {
list2_funtion = 0;
tmp = LISTBOX_GetSel(ListItem2);
if(tmp == 1){//delete
LISTBOX_DeleteItem(ListItem,select);
select--;//菜单从1开始,0是add new
LISTBOX_SetSel(ListItem,select);
tmp = 0;
for(count=0;count < Dogg_REGISTED_MASK;count++)
{
p_reg = &registed_dogg[count];
if(tmp == select)
{
p_reg->doggtype = 0xff;
p_reg->ID = 0xffff;
p_reg->name[0] = NULL;
flag_spiflash_write |= (1<<count);
break;
}
else if(p_reg->doggtype !=0xff)
{
tmp ++;
}
}
save_RegistDoggs_in_flash();
}
WM_HideWindow(ListItem2);
WM_SetFocus(ListItem);
} else {
ListItem2_popup(2);
LISTBOX_SetString(ListItem2,"Cancel",0);
LISTBOX_SetString(ListItem2,"Delete",1);
LISTBOX_SetSel(ListItem2,0);
list2_funtion=1;
}
break;
case MENU_AddDoggs:
if(select == 0)break;
ListIndex[MENU_AddDoggs]=select;
select--;
link_to_directory(select);
dogg_name_input_page();
break;
case MENU_EditDoggName:
if(!keyboard_en)
keyboard_popup();
else if(keyboard_enter_key(12) == 0x0d)//enter
{
tmp = strlen(text_keyboard);
if(tmp > 0)
{
tmp = ListIndex[MENU_AddDoggs]-1;
p_dogg = &dogg[tmp];
p_reg = &registed_dogg[p_dogg->reg_index];
strcpy(p_reg->name,text_keyboard);
strcpy(p_dogg->name,text_keyboard);
write_doggName(p_dogg->ID,text_keyboard);
save_RegistDoggs_in_flash();
scroll_pos=0;
DoggsSelection_page();
LISTBOX_SetSel(ListItem,ListIndex[MENU_AddDoggs]);
}
}
break;
default:
//any_menu=0;
break;
}
return 0;
}
u8 exit_key(void)
{
switch (menu_page)
{
default:
case MENU_MainMenu:
reading_mode_option=0;
homepage();
LISTBOX_SetSel(ListItem,speaker);
break;
case MENU_GoPage:
break;
// case MENU_SelectSpeaker:
case MENU_Sounds:
if(list2_funtion)
{
WM_HideWindow(ListItem2);
list2_funtion=0;
}
else if (reading_mode_option)
{
PlaySounds_page();
}
else
{
MainMenu_page(0);
LISTBOX_SetSel(ListItem,ListIndex[MENU_MainMenu]);
}
break;
case MENU_Setting:
ListIndex[MENU_MainMenu] = 2;
MainMenu_page(0);
LISTBOX_SetSel(ListItem,2);
break;
case MENU_CardFolder:
if(folderdeep==0 && btn_horz)
{
CreateHunt_page_two();
}
else if(folderdeep==0 && reading_mode_option)
{
PlaySounds_page();
}
else
{
exit_DirList();
}
break;
case MENU_FavorriteSounds:
flag_disable_list = LISTBOX_GetNumItems(ListItem)-1;
if(list2_funtion ==0)
{
if (reading_mode_option)
{
PlaySounds_page();
}
else
{
Sounds_page();
LISTBOX_SetSel(ListItem,ListIndex[MENU_Sounds]);
}
}
else
{
WM_HideWindow(ListItem2);
list2_funtion=0;
WM_SetFocus(ListItem);
}
break;
case MENU_ExpertHunts:
if(list2_funtion)
{
list2_funtion=0;
WM_HideWindow(ListItem2);
WM_SetFocus(ListItem);
LISTBOX_SetBkColor(ListItem,LISTBOX_CI_SELFOCUS,get_color_NightMode(COLOR_ListItem_SELECTED));
break;
}
else if(reading_mode_option)
{
PlaySounds_page();
}
else
{
MainMenu_page(0);
LISTBOX_SetSel(ListItem,ListIndex[MENU_MainMenu]);
}
//flag_disable_list = LISTBOX_GetNumItems(ListItem)-1;
break;
case MENU_CreatHunt2:
if(sub_expert_menu)
{
WM_HideWindow(ListItem2);
list2_funtion=0;
sub_expert_menu=0;
if(btn_horz==1)
{
WM_ShowWindow(Btnexp[0]);
WM_ShowWindow(Btnexp[1]);
WM_ShowWindow(Btnexp[2]);
}
WM_SetFocus(ListItem3);
break;
}
WM_HideWindow(Btnexp[0]);
WM_HideWindow(Btnexp[1]);
WM_HideWindow(Btnexp[2]);
btn_horz=0;
//CreateHunt_page();
//break;
case MENU_CreatHuntName:
if(keyboard_en)
{
GUI_EndDialog(hKeyboard,0);
keyboard_en=0;
}else{
WM_SetFocus(ListItem);
menu_page=MENU_ExpertHunts;
ExpertHunts_page();
LISTBOX_SetSel(ListItem,ListIndex[MENU_ExpertHunts]);
}
break;
case MENU_SoundSettings:
if(list2_funtion ==0)
{
Settings_page(0);
LISTBOX_SetSel(ListItem,ListIndex[MENU_Setting]);
}
else
{
WM_HideWindow(ListItem2);
list2_funtion=0;
WM_SetFocus(ListItem);
}
break;
case MENU_DecoySettings:
case MENU_DisplaySettings:
case MENU_DeviceInfo:
case MENU_HotKeySettings:
case MENU_SyncSettings:
if(last_menu == MENU_MainMenu){
ListIndex[MENU_MainMenu] = 2;
MainMenu_page(0);
LISTBOX_SetSel(ListItem,2);
}
else //if(last_menu == MENU_Setting)
{
Settings_page(0);
LISTBOX_SetSel(ListItem,ListIndex[MENU_Setting]);
}
break;
case MENU_MyDoggs:
if(list2_funtion) {
list2_funtion = 0;
WM_HideWindow(ListItem2);
WM_SetFocus(ListItem);
}
#if 0 //会死机
else if(last_menu == MENU_GoPage){
frame_created = 0;
GUI_EndDialog(main_window, 0);
first_window = CreateFRM0();
#ifdef FIND_REGISTED_ONLY
TEXT_SetText(TextWin[0], "Welcome to The Dogg Net\nGame Caller System");
TEXT_SetText(TextWin[1], "To start hunting\nplease register your doggs");
LISTBOX_SetString(ListItem, "Go!",0);
#else
TEXT_SetText(TextWin[0], "No Devices Detected");
TEXT_SetText(TextWin[1], "");
LISTBOX_SetString(ListItem, "Retry Connection",0);
LISTBOX_AddString(ListItem, "My Doggs");
#endif
LISTBOX_SetSel(ListItem,0);
menu_page = MENU_GoPage;
task1_state = TaskSTATE_GO;
}
#endif
else {
Settings_page(0);
LISTBOX_SetSel(ListItem,ListIndex[MENU_Setting]);
}
break;
case MENU_AddDoggs:
save_RegistDoggs_in_flash();
MyDoggs_page(0);
break;
case MENU_EditDoggName:
if(keyboard_en)
{
GUI_EndDialog(hKeyboard,0);
keyboard_en=0;
}
else{
WM_SetFocus(ListItem);
MyDoggs_page(0);
LISTBOX_SetSel(ListItem,ListIndex[MENU_MyDoggs]);
}
break;
case MENU_Hotx:
SelectHotKey_page();
}
return 0;
}
void system_set_powersave(u8 newstate)
{
switch(newstate)
{
case 0://off
set_brightness(0);
BackLight_OFF();
RF915_MODE3();
SYSTEM_POWER_OFF();
flag_power =0;
break;
case 1://turn off backlight
flag_power =1;
break;
default://on
//if(flag_power ==1)
{
//MCU NORMAL
set_brightness(brightness);
BackLight_ON();
//RF915_MODE0();
//GUI_Delay(10);
}
flag_power =2;
break;
}
}
u8 KEY_Handler(void)
{
u8 key;
if(key_code == KEY_NONE)return 0xff;
key = key_code;
key_code = KEY_NONE;
//按键亮屏
display_time=0;
if(flag_power == 1)
{
system_set_powersave(2);
return 0;
}
////////////
switch(key)
{
default:
break;
case KEY_UP:
up_key();
refresh_arrows(-1);
break;
case KEY_DOWN:
down_key();
refresh_arrows(1);
break;
case KEY_MENU:
reading_mode_option=0;
menu_key();
refresh_arrows(0);
break;
case KEY_POWER_OFF:
set_brightness(0);
BackLight_OFF();
SYSTEM_POWER_OFF();
break;
case KEY_ENTER:
enter_key();
current_menu = menu_page;
refresh_arrows(0);
break;
case KEY_BACK:
exit_key();
if(!list2_funtion)scroll_pos=0;
refresh_arrows(0);
current_menu = menu_page;
break;
case KEY_LEFT:
adj_key( KEY_LEFT);
refresh_arrows(0);
break;
case KEY_RIGHT:
adj_key(KEY_RIGHT);
refresh_arrows(0);
break;
case KEY_HOT1:
case KEY_HOT2:
case KEY_HOT3:
case KEY_HOT4:
hot_key(key - KEY_HOT1 );
break;
case KEY_HOT1_SETUP:
case KEY_HOT2_SETUP:
case KEY_HOT3_SETUP:
case KEY_HOT4_SETUP:
setup_hot_key(key - KEY_HOT1_SETUP );
refresh_arrows(0);
current_menu=menu_page;
break;
}
#if 0
if(stop_out)//((menu_page!=MENU_CreatHunt2)||(key==KEY_BACK))&&(
{
if((!list2_funtion)&&(!playing_expert))
{
write_register(current_dogg->ID,4,3);
sound_info.state = SOUND_STOPPED;
sound_info.current_time =0;
}
}
if((menu_page!=MENU_CreatHunt2)&&(!sub_expert_menu))
{
if(stop_out)//((menu_page!=MENU_CreatHunt2)||(key==KEY_BACK))&&(
{
write_register(current_dogg->ID,4,3);
sound_info.state = SOUND_STOPPED;
sound_info.current_time =0;
}
stop_out = 0;
}
#endif
return 0;
}
void check_system_state(void)
{
u8 spk;
DOGG_Type * p_spk;
for(spk=0;spk< Doggs_List_MAX;spk++)
{
p_spk = &dogg[spk];
if(check_dogg_online(p_spk,Dogg_ONLINE_MASK))
{
if(++p_spk->time_connected == 120)//disconnect
{
if(p_spk->status !=0)New_icon_state |=(1<<spk);
p_spk->MemState &= (u8)~Dogg_ONLINE_MASK;
//p_spk->status = 0 ;
}
}
}
}
void uart_send_ack(u8 spk)
{
u8 buf[3];
if(spk < Doggs_List_MAX)
{
buf[BUFFER_COMMAND]=COMMAND_FromRemote |UART_COMMAND_ACK;
buf[BUFFER_LENGTH]=1;//1个参数
buf[BUFFER_PARAM1]=0x80;
sendtx(dogg[spk].ID,buf,TRANSFER_ONCE,UART_COMMAND_ACK);
}
}
void uart_get_status(u8 spk)
{
u8 buf[3];
if(spk < Doggs_List_MAX)
{
buf[BUFFER_COMMAND]=COMMAND_FromRemote |UART_COMMAND_ACK;
buf[BUFFER_LENGTH]=0;//0个参数
sendtx(dogg[spk].ID,buf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
}
void send_poweron(u8 spk)
{
u8 * p;
u8 buf[5+BUFFER_PARAM1];
DOGG_Type * pspk;
if(spk >= Doggs_List_MAX )return;
buf[BUFFER_COMMAND]=COMMAND_FromRemote |UART_COMMAND_ON;
buf[BUFFER_LENGTH] = 4;
pspk= &dogg[spk];
p = &buf[BUFFER_PARAM1];
*p++ = pspk->setting;
*p++ = pspk->main_volume;
*p++ = pspk->TweeterVol;
*p = pspk->SubwooferVol;
sendtx(pspk->ID,buf,TRANSFER_ONCE,UART_COMMAND_ACK);
}
void arrange_dogg(u8 mode)
{
u8 spk,k,tmp;
DOGG_Type tmp_dogg;
if(mode==0)
{
for(k=Doggs_List_MAX-1;k;k--)
{
for(spk=0;spk<k;spk++)
{
if(dogg[spk].doggtype > dogg[spk+1].doggtype)
{
memcpy(&tmp_dogg,&dogg[spk],sizeof(DOGG_Type));
memcpy(&dogg[spk],&dogg[spk+1],sizeof(DOGG_Type));
memcpy(&dogg[spk+1],&tmp_dogg,sizeof(DOGG_Type));
}
if((!(dogg[spk].status & STATUS_POWER_MASK))&&(dogg[spk+1].status & STATUS_POWER_MASK)&&(dogg[spk].doggtype!=0xFF)&&(dogg[spk+1].doggtype!=0xFF))
{
memcpy(&tmp_dogg,&dogg[spk],sizeof(DOGG_Type));
memcpy(&dogg[spk],&dogg[spk+1],sizeof(DOGG_Type));
memcpy(&dogg[spk+1],&tmp_dogg,sizeof(DOGG_Type));
}
}
}
}
else
{
tmp=id_to_spk(current_dogg->ID);
memcpy(&tmp_dogg,&dogg[0],sizeof(DOGG_Type));
memcpy(&dogg[0],current_dogg,sizeof(DOGG_Type));
memcpy(&dogg[tmp],&tmp_dogg,sizeof(DOGG_Type));
}
}
void link_to_directory(u8 spk_num)
{
u8 k;
DOGG_registed * p_reg;
DOGG_Type * p_spk;
p_spk = &dogg[spk_num];
//已存在
for(k=0;k < Doggs_REG_MAX;k++)
{
p_reg = &registed_dogg[k];
if(p_reg->ID == p_spk->ID)goto ASSIGNED;
}
//空位置
for(k=0;k < Doggs_REG_MAX;k++)
{
p_reg = &registed_dogg[k];
if(p_reg->ID == 0xffff)goto ASSIGNED;
}
p_spk->reg_index = 0xff;
p_spk->tree.DirTree = (u32)0xffffffff;
p_spk->hunt.DirTree = (u32)0xffffffff;
p_spk->favorite.DirTree = (u32)0xffffffff;
p_spk->MemState = 0;
return;
////////////////////////////
ASSIGNED:
p_spk->reg_index = k;
p_spk->tree.DirTree = address_tree(k, 0);
p_spk->hunt.DirTree = address_tree(k, EXPT_HUNTS_OFFST);
p_spk->favorite.DirTree = address_tree(k, FAVORITE_OFFSET);
p_reg = &registed_dogg[k];
p_reg->doggtype=p_spk->doggtype;
p_reg->ID = p_spk->ID;
}
void send_search_command(u16 dogg_index)
{
u8 TxBuf[Doggs_List_MAX*6+2];
u8 j;
u8 *ps;
TxBuf[BUFFER_COMMAND]=COMMAND_FromRemote |UART_COMMAND_SEARCH;
TxBuf[BUFFER_LENGTH]=0;
if(dogg_index == 0xff)//全部
{
sendtx(0xffff,TxBuf,TRANSFER_ONCE,UART_COMMAND_SEARCH);
}
else if(dogg_index == 0xfe)//屏蔽已找到的
{
for(j=0;j < Doggs_List_MAX;j++){
if(dogg[j].doggtype != 0xff)
{
TxBuf[BUFFER_LENGTH] += 6;
memcpy(&TxBuf[BUFFER_PARAM1+0],&dogg[j].manufacturer,4);
ps = (u8*)&dogg[j].ID;
TxBuf[BUFFER_PARAM1+4] = *(ps+1);
TxBuf[BUFFER_PARAM1+5] = *ps;
}
}
sendtx(0xffff,TxBuf,TRANSFER_ONCE,UART_COMMAND_SEARCH);
}
else if(dogg_index < Doggs_REG_MAX)//指定
{
TxBuf[BUFFER_COMMAND]=COMMAND_FromRemote |UART_COMMAND_SEARCH;
TxBuf[BUFFER_LENGTH]=0;
sendtx(registed_dogg[dogg_index].ID,TxBuf,TRANSFER_ONCE,UART_COMMAND_SEARCH);
}
}
void send_ReadStatus_command(u16 dogg_index)
{
u8 str1[3];
str1[BUFFER_COMMAND]=COMMAND_FromRemote |UART_COMMAND_ACK;
str1[BUFFER_LENGTH]=0;
sendtx(dogg[dogg_index].ID,str1,TRANSFER_ONCE,UART_COMMAND_ACK);
}
void time_update(void)
{
char intBuff[10];
#ifdef DSD_CODE
static u16 pTimeSound=0;
static u16 play_time =0;
if(flag_1sB==1)
{
flag_1sB=0;
if(play_time < sound_info.current_time)
{
play_time++;
}
else
{
play_time = 0;
if((sound_info.state!=SOUND_STOPPED)&&(sound_info.duration_time))
{
if((playing_expert)&&(playing_expert<tmp_expert_idx))
{
playing_expert++;
TEXT_SetText(TopStatusWin[5],"00:00");
sound_info.current_time=0;
sound_info.duration_time=0;
send_FileDirNode_cmd(dogg[speaker].ID,UART_COMMAND_PlayFile,tmp_expert[playing_expert-1]);
sound_info.state = SOUND_PLAYING;
}
else if (playing_expert)
{
playing_expert=0;
sound_info.state = SOUND_PAUSED;
BUTTON_SetText(Btnexp[1],"Play");
}
else if(!(current_dogg->setting & STATE_LOOP_MASK)) //20200806 joey 单次播放结束进入
{
sound_info.state=SOUND_STOPPED;
LISTBOX_SetString(ListItem2,"Play",0);
list2_funtion = 1;
}
}
}
//sprintf(intBuff, "a%02u:%02u", sound_info.current_time/60, sound_info.current_time%60);
sprintf(intBuff, "%02u:%02u", play_time/60, play_time%60);
TEXT_SetText(TopStatusWin[5],intBuff);
}
else if(sound_info.current_time!=pTimeSound)
{
//sprintf(intBuff, "b%02u:%02u", sound_info.current_time/60, sound_info.current_time%60);
sprintf(intBuff, "%02u:%02u", play_time/60, play_time%60);
TEXT_SetText(TopStatusWin[5],intBuff);
}
pTimeSound=sound_info.current_time;
#endif
if(flag_1s==1)
{
flag_1s=0;
#ifdef SAVE_DELAY
if(save_delay && (--save_delay)==0)
{
saveCoff_in_stm32();
save_RegistDoggs_in_flash();
}
#endif
if(timer_enable == 0 /*&& timer_count_start*/)
{
if(++sec>=60)
{
sec=0;
if(++min > 999)
{
min=999;
sec=59;
}
adc_bat=ADC_Get_aveg(ADC_Channel_12,10);//(0~4095);
show_bat_icon();
}
sprintf(intBuff, "%d:%02d", min, sec);
TEXT_SetText(TopStatusWin[6],intBuff);
}
check_system_state();
icon_refresh(0);//??
if(++display_time == DISPLAY_TIME)
{
system_set_powersave(1);
}
else if(display_time == POWEROFF_TIME)
{
system_set_powersave(0);
}
}
}
u8 flag_setup915;
extern vu8 uart2_ByteCount;
extern vu8 uart2_rx_buffer[];
void setup_RF915(u8 baudrate, u8 fcc)
{
u8 count;
u8 read_config_rf[]={0xc1,0xc1,0xc1};
u8 write_config_rf[]={0xc0,0x00,0x00,RF_BAUDRATE,0x96,0x44};
if(fcc)write_config_rf[5]=0x40;//FCC_TEST_915
RF915_MODE3();
USART2_Config(9600);
GUI_Delay(100);
flag_setup915=1;
while(!RF915_AUX);
GUI_Delay(250);// 600ms
while(1)
{
while(!RF915_AUX);
GUI_Delay(5);
uart2_ByteCount=0;
uart2_tx_output(read_config_rf,3);
USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
GUI_Delay(15);
while(!RF915_AUX);
GUI_Delay(5);
for(count=1;count < 6;count++)
{
if(uart2_rx_buffer[count] != write_config_rf[count])
{
uart2_ByteCount=0;
uart2_tx_output(write_config_rf,6);
USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
GUI_Delay(100);
break;
}
}
if(count == sizeof(write_config_rf))break;
}
while(!RF915_AUX);
RF915_MODE0();
uart2_ByteCount=0;
flag_setup915=0;
USART2_Config(115200);
}
void dogg_FCC_test_RF915(u8 start)
{
u8 TxBuf[4];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote |UART_COMMAND_TEST;
TxBuf[BUFFER_LENGTH]=1;
TxBuf[BUFFER_PARAM1]=2;
sendtx(dogg[speaker].ID,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
void Remote_FCC_test_RF915(void)
{
u8 k;
if(RF915_AUX);
{
for(k = 0;k < 54;k++)
{
uart2_tx_buffer[k]= 0xAA;
}
uart2_tx_in = 54;
uart2_tx_out = 0;
USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
}
}
void RF_test_send_frame(void)
{
static u8 test_txframe;
u8 TxBuf[RF915_TEST_TX];
if(++test_txframe >100)test_txframe=1;
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote |UART_COMMAND_TEST;
TxBuf[BUFFER_LENGTH]=RF915_TEST_TX;
TxBuf[BUFFER_PARAM1]=1;
TxBuf[BUFFER_PARAM1+1]=test_txframe;
sendtx(dogg[speaker].ID,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
void RF_test915_start(u8 baudrate)
{
u8 TxBuf[4];
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote |UART_COMMAND_TEST;
TxBuf[BUFFER_LENGTH] = 1;
TxBuf[BUFFER_PARAM1] = baudrate;
sendtx(dogg[speaker].ID,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
task1_delay=RF_TEST_StartDelay1;
task1_state=TaskSTATE_TESTBAUDRATE;
}
void RF_test915_stop(u8 baudrate)
{
u8 TxBuf[4];
task1_state=TaskSTATE_NORMAL;
TxBuf[BUFFER_COMMAND]= COMMAND_FromRemote |UART_COMMAND_TEST;
TxBuf[BUFFER_LENGTH]=1;
TxBuf[BUFFER_PARAM1]=0;
sendtx(dogg[speaker].ID,TxBuf,TRANSFER_WaitAck,UART_COMMAND_ACK);
}
u8 test_baudrate;
u8 test_rxframe = 0;
u8 test_recv_frame = 0;
u8 test_ack = 0;
u8 test_recv_frame100 = 0;
u8 test_ack100 = 0;
u8 test_flag_testresult;
void display_testresult(void)
{
char buf[32];
sprintf(buf, "%d/%d/%d (%d/%d/100)",test_recv_frame,test_ack,test_rxframe,test_recv_frame100,test_ack100);
TEXT_SetText(MainTitle,buf);
}
void RF_test_result(u8 *out)
{
if(*out <= test_rxframe)//新周期
{
test_recv_frame100 = test_recv_frame;
test_ack100 = *(out+2);
test_recv_frame =1;
}
else
{
test_recv_frame++;
}
test_rxframe = *out;
test_ack=*(out+1);
test_flag_testresult=1;
}
void polling(void)
{
recvRx();
time_update();
if((uart2_tx_out != uart2_tx_in) && RF915_AUX)USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
}
u8 Progress_PercentTime;
void task1_ShowSearchingProgress(u8 percent) {
static u8 last_percent = 0;
if(percent >100)percent=100;
if(percent != last_percent)
{
PROGBAR_SetValue(ProgWin, percent);
last_percent = percent;
}
}
void flash_erase_nbytes(u32 startAddress, u32 nbytes)
{
u32 offsetAddress,sectorPosition,sectorStartAddress;
if(nbytes > DOGG_MEMORY_SIZE)return;
#ifdef USE_SPI_FLASH
offsetAddress = FLASH_DATA_STARTADDR+startAddress; //计算实际偏移地址
sectorPosition = offsetAddress/SPI_FLASH_SectorSize; //计算扇区地址
sectorStartAddress = sectorPosition*SPI_FLASH_SectorSize; //对应扇区的首地址
while(nbytes > SPI_FLASH_SectorSize)
{
SPI_FLASH_SectorErase(sectorStartAddress);
nbytes -=SPI_FLASH_SectorSize;
sectorStartAddress += SPI_FLASH_SectorSize;
}
if(nbytes)
{
SPI_FLASH_SectorErase(sectorStartAddress);
}
#else
offsetAddress = (FLASH_DATA_STARTADDR-FLASH_BASE)+startAddress; //计算去掉0X08000000后的实际偏移地址
sectorPosition = offsetAddress/STM32_SECTOR_SIZE; //计算扇区地址,对于STM32F103VET6为0~255
sectorStartAddress = sectorPosition*STM32_SECTOR_SIZE + FLASH_BASE; //对应扇区的首地址
FLASH_Unlock(); //解锁flash
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
while(nbytes > STM32_SECTOR_SIZE)
{
FLASH_ErasePage(sectorStartAddress);//擦除整页
sectorStartAddress += STM32_SECTOR_SIZE;
nbytes -= STM32_SECTOR_SIZE;
}
if(nbytes)
{
FLASH_ErasePage(sectorStartAddress);//擦除整页
}
FLASH_Lock(); //锁定flash
#endif
}
u8 new_doggs;
ErrorStatus check_flash_CRC(tree_type * p_tree)
{
u32 add;
u32 CRCTree;
add = (u32)FLASH_DATA_STARTADDR + p_tree->DirTree;
CRC_ResetDR();
#ifdef USE_SPI_FLASH
CRCTree = CRC_CalcBlockCRC_SPI_FLASH(p_tree->DirTree, ((p_tree->sizeTree)/4));
#else
CRCTree = CRC_CalcBlockCRC((u32 *)add, (p_tree->sizeTree)/4);
#endif
if(CRCTree == p_tree->CRCTree)
return SUCCESS;
else
return ERROR;
}
void task1_progress(void)
{
static u8 last_progress;
static u8 dogg_index;
static u8 block_index;
static u8 error_count;
u8 k,count;
char str1[50];
char * p;
DOGG_registed * p_reg;
DOGG_Type * p_dogg;
switch(task1_state)
{
default:
#if 1
if((menu_page != MENU_CreatHuntName)&&(menu_page != MENU_CreatHunt2))
{
if(show_one_bar)
{
show_one_bar=0;
icon_refresh(1);
}
else
{
icon_refresh(0);
}
}
#endif
break;
case TaskSTATE_GO:
break;
//查找已登记的
case TaskSTATE_CheckDogg:
TEXT_SetText(TextWin[0], "Connecting to Master Device");
TEXT_SetText(TextWin[1], "Searching ...");
Search_progress = 0;
PROGBAR_SetValue(ProgWin, 0);
WM_ShowWindow(ProgWin);
WM_HideWindow(ListItem);
for(k=0;k<Doggs_List_MAX;k++)
{
reset_dogg(k);
}
count =0;
for(k = 0;k < Doggs_REG_MAX;k++){
p_reg = &registed_dogg[k];
if(p_reg->doggtype >= TOP_DOGG && p_reg->doggtype <= TRIPLE_DOGG && p_reg->ID != 0xffff)count++;
}
if(count){
#ifdef FIND_REGISTED_FIRST
Progress_PercentTime = (SEARCH_Delay + AckTime*2*count)/100;
#else
Progress_PercentTime = (AckTime*2*count)/100;
#endif
dogg_index=0;
task1_state = TaskSTATE_CheckDoggNext;
}
else
{
Progress_PercentTime = SEARCH_Delay/100;
task1_state = TaskSTATE_CheckDoggFinished;
}
break;
case TaskSTATE_CheckDoggNext:
while(dogg_index < Doggs_REG_MAX)
{
p_reg = &registed_dogg[dogg_index];
if(p_reg->doggtype >= TOP_DOGG && p_reg->doggtype <= TRIPLE_DOGG && p_reg->ID != 0xffff)
{
last_progress = 0;
send_search_command(dogg_index);//初次查询
task1_delay = AckTime;
task1_state = TaskSTATE_WaitDoggAck1;
return;
}
dogg_index++;
}
task1_state = TaskSTATE_CheckDoggFinished;
break;
case TaskSTATE_WaitDoggAck1:
if(flag_ack == UART_COMMAND_SEARCH)
{
dogg_index++;
task1_state = TaskSTATE_CheckDoggNext;
}
else if(task1_delay)
{
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
}
else if(last_progress)
{
dogg_index++;
task1_state = TaskSTATE_CheckDoggNext;
}
else
{
send_search_command(dogg_index);//再次查询
task1_delay = AckTime;
last_progress++;
}
break;
case TaskSTATE_CheckDoggFinished:
#ifdef FIND_REGISTED_ONLY
task1_state = TaskSTATE_SearchFinished;
#else
send_search_command(0xff);
last_progress = 0;
task1_delay = SEARCH_Delay;
task1_state = TaskSTATE_WaitSearch1Ack;
#endif
break;
case TaskSTATE_WaitSearch1Ack:
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
if(task1_delay < (SEARCH_Delay>>1)){
send_search_command(0xfe);
task1_state = TaskSTATE_WaitSearch2Ack;
}
break;
case TaskSTATE_WaitSearch2Ack:
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
if(task1_delay ==0){
task1_state = TaskSTATE_SearchFinished;
}
break;
/////////////////////////////////////
case TaskSTATE_SearchFinished:
dogg_index = 0;
PROGBAR_SetValue(ProgWin, 100);
count=0;
p_dogg = dogg;
for(k=0;k<Doggs_List_MAX;k++){
if(check_dogg_online(p_dogg,0xff))count++;
p_dogg++;
}
if(count)
{
arrange_dogg(0);
if(count==1){
strcpy(str1, "1 Device Detected");
}else{
sprintf(str1, "%u Devices Detected",count);
}
if(searching_mode == SearchMode_startup){
TEXT_SetText(TextWin[0], str1);
TEXT_SetText(TextWin[1], "Finished");
}else if(searching_mode == SearchMode_SyncAll){
TEXT_SetText(TextWin[1],str1);
}else if(searching_mode == SearchMode_goFound){
TEXT_SetText(TextWin[0],str1);
TEXT_SetText(TextWin[1], "");
}
last_progress =0;
if(searching_mode == SearchMode_startup || searching_mode == SearchMode_SyncAll){
task1_delay=500;
}else if(searching_mode == SearchMode_goFound){
searching_mode = SearchMode_startup;
}
task1_state = TaskSTATE_TurnOnDevice;
}
else
{
strcpy(str1,"No Devices Detected");
if(searching_mode == SearchMode_startup){
TEXT_SetText(TextWin[0], str1);
TEXT_SetText(TextWin[1], "");//
ListItem_SetItumTo(2);
LISTBOX_SetString(ListItem, "Retry Connection",0);
LISTBOX_SetString(ListItem, "My Doggs",1);
WM_ShowWindow(ListItem);
task1_state=TaskSTATE_GO;
}else if(searching_mode == SearchMode_SyncAll){
TEXT_SetText(TextWin[1],str1);
task1_delay = 500;
task1_state = TaskSTATE_SyncDisplay;
}
}
break;
/////////////////
case TaskSTATE_TurnOnDevice:
if(task1_delay)return;//等待,显示搜索结果0.5秒
p_dogg = &dogg[dogg_index];
if(p_dogg->doggtype == 0xff)
{
//p_dogg->MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
return;
}
if(searching_mode)
{
TEXT_SetText(TextWin[0], "Synchronizing Devices");
sprintf(str1,"Turn on %s dogg ",get_DoggTypeString(p_dogg->doggtype));
p = str1+strlen(str1);
display_doggName2buffer(p,p_dogg->ID);
TEXT_SetText(TextWin[1], str1);
}
last_progress = 0;
Search_progress = 0;
Progress_PercentTime = (TURNON_Delay+220)/100;
PROGBAR_SetValue(ProgWin, 0);
send_poweron(dogg_index);//开机
task1_delay = TURNON_Delay;
task1_state = TaskSTATE_WaitTurnOnDevice;
break;
case TaskSTATE_WaitTurnOnDevice:
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
if(task1_delay)return;
p_dogg = &dogg[dogg_index];
if(p_dogg->status & STATUS_POWER_MASK)
{
task1_state = TaskSTATE_ReadVersion;
}
else if(++last_progress >= 5)
{
p_dogg->MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}
else
{
send_poweron(dogg_index);//开机
task1_delay = TURNON_Delay;
}
break;
case TaskSTATE_ReadVersion:
p_dogg = &dogg[dogg_index];
p_dogg->FwVerssion[0]=NULL;
read_register(p_dogg->ID,0x07,0);//读取版本号
last_progress = 0;
task1_delay = AckTime;
task1_state = TaskSTATE_WaitSyncVersion;
break;
case TaskSTATE_WaitSyncVersion:
p_dogg = &dogg[dogg_index];
if(flag_ack == UART_COMMAND_READ)
{
p_dogg->name[0]=NULL;
last_progress = 0;
read_register(p_dogg->ID,0x08,0);
task1_delay = AckTime;
task1_state = TaskSTATE_WaitSyncName;
}else if(task1_delay){
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
}else if(last_progress >= 5){
p_dogg->MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}else {
read_register(p_dogg->ID,0x07,0);//重读版本号
last_progress++;
task1_delay = AckTime;
}
break;
case TaskSTATE_WaitSyncName:
if(flag_ack == UART_COMMAND_READ)
{
task1_state = TaskSTATE_LinkRegisted;
}else if(task1_delay) {
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
}else if(last_progress >= 5){
dogg[dogg_index].MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}else {
read_register(dogg[dogg_index].ID,0x08,0);//重读名称
last_progress++;
task1_delay = AckTime;
}
break;
//////////////////////////////////////
case TaskSTATE_LinkRegisted:
link_to_directory(dogg_index);//找一个位置存放sync内容
p_dogg = &dogg[dogg_index];
if(p_dogg->reg_index == 0xff)//没位置了
{
p_dogg->MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}
else
{
if(searching_mode == SearchMode_SyncOne || searching_mode == SearchMode_SyncAll)
{
TEXT_SetText(TextWin[1], "Synchronizing ...");
task1_ShowSearchingProgress(0);
Search_progress =0;
Progress_PercentTime = 500/5;// 按5%
}
task1_state = TaskSTATE_ReadTreeSize;
}
break;
case TaskSTATE_ReadTreeSize:
last_progress =0;
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_TreeSize,UART_COMMAND_Sync);//获取tree大小和CRC
task1_delay = SYNC_TreeAckTime;
task1_state = TaskSTATE_WaitTreeSize;
break;
case TaskSTATE_WaitTreeSize:
if(flag_ack == UART_COMMAND_Sync){
task1_state = TaskSTATE_ReadExpHSize;
}else if(task1_delay) {
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
}else if(last_progress > 5){
dogg[dogg_index].MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}else {
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_TreeSize,UART_COMMAND_Sync);//获取tree大小和CRC
last_progress++;
task1_delay = SYNC_TreeAckTime;
}
break;
case TaskSTATE_ReadExpHSize:
last_progress =0;
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_ExpertHuntSize,0);//获取expH大小和CRC
task1_delay = AckTime2;
task1_state = TaskSTATE_WaitExpHSize;
error_count =0;
break;
case TaskSTATE_WaitExpHSize:
if(flag_ack == UART_COMMAND_Sync){
task1_state = TaskSTATE_ReadFavSize;
}else if(task1_delay) {
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
}else if(last_progress > 5){
dogg[dogg_index].MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}else {
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_ExpertHuntSize,0);//获取expH大小和CRC
last_progress++;
task1_delay = AckTime2;
}
break;
case TaskSTATE_ReadFavSize:
last_progress =0;
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_FavoriteSize,0);//获取Fav大小和CRC
task1_delay = AckTime2;
task1_state = TaskSTATE_WaitFavSize;
break;
case TaskSTATE_WaitFavSize:
if(flag_ack == UART_COMMAND_Sync)
{
task1_state = TaskSTATE_SYNC_start;
}else if(task1_delay) {
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
}else if(last_progress > 5){
dogg[dogg_index].MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}else {
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_FavoriteSize,0);//获取Fav大小和CRC
last_progress++;
task1_delay = AckTime2;
}
break;
//////////////////////////////////
//////////////////////////////////
case TaskSTATE_SYNC_start:
p_dogg = &dogg[dogg_index];
p_dogg->MemState = 0;
if(p_dogg->reg_index >= Doggs_REG_MAX)
{
p_dogg->MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
break;
}
if(p_dogg->tree.sizeTree == 0){//没有卡
p_dogg->hunt.sizeTree=0;
p_dogg->favorite.sizeTree=0;
p_dogg->MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
break;
}
k = (p_dogg->tree.sizeTree+(SYNC_BLOCK_SIZE-1))/SYNC_BLOCK_SIZE;
k += (p_dogg->hunt.sizeTree+(SYNC_BLOCK_SIZE-1))/SYNC_BLOCK_SIZE;
k += (p_dogg->favorite.sizeTree+(SYNC_BLOCK_SIZE-1))/SYNC_BLOCK_SIZE;
if(searching_mode == SearchMode_startup)
{
TEXT_SetText(TextWin[0], "Synchronizing Devices");
sprintf(str1,"Synchronizing %s dogg ",get_DoggTypeString(p_dogg->doggtype));
p = str1+strlen(str1);
display_doggName2buffer(p,p_dogg->ID);
TEXT_SetText(TextWin[1], str1);
task1_ShowSearchingProgress(0);
Search_progress =0;
Progress_PercentTime = (k * SYNC_TransTime)/100;
}
else
{
Progress_PercentTime = (k * SYNC_TransTime)/95;
}
if(Progress_PercentTime==0)Progress_PercentTime=1;
task1_state = TaskSTATE_SYNC_ExpertHunt;
new_doggs = 0;
break;
case TaskSTATE_SYNC_ExpertHunt:
error_count =0;
p_dogg = &dogg[dogg_index];
if(p_dogg->hunt.sizeTree ==0){
if(*(u16*)(FLASH_DATA_STARTADDR + p_dogg->hunt.DirTree)!=0xffff){
flash_erase_nbytes(address_tree(p_dogg->reg_index, EXPT_HUNTS_OFFST),2);
}
task1_state = TaskSTATE_WaitSyncNextDogg;
break;
}
else if(check_flash_CRC(&p_dogg->hunt) == SUCCESS)
{
task1_state = TaskSTATE_SYNC_Favorate;
break;
}
new_doggs =1;
flash_erase_nbytes(address_tree(p_dogg->reg_index, EXPT_HUNTS_OFFST),p_dogg->hunt.sizeTree);
last_progress=0;
block_index = 0;
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_ExpertHunt,0);
task1_delay = SYNC_TransTime+20;
task1_state = TaskSTATE_WaitExpertHunt;
break;
case TaskSTATE_WaitExpertHunt:
if(flag_ack == ACK_SYNC_TheEnd){
task1_state = TaskSTATE_CheckSyncHunt;
}
else if(flag_ack == UART_COMMAND_Sync){//下一个block
last_progress=0;
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_ExpertHunt,++block_index);
task1_delay = SYNC_TransTime+20;
}else if(task1_delay) {//等待时间
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
}else if(last_progress > 5){//失败
dogg[dogg_index].MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}else {//没收到
last_progress++;
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_ExpertHunt,block_index);//重做
task1_delay = SYNC_TransTime+20;
}
break;
case TaskSTATE_CheckSyncHunt:
p_dogg = &dogg[dogg_index];
if(p_dogg->hunt.sizeTree == 0)
{
p_dogg->hunt.CRCTree = 0;
task1_state = TaskSTATE_SyncHuntOk;
}
else if(check_flash_CRC(&p_dogg->hunt) != SUCCESS)
{
if(++error_count > 2){
p_dogg->MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}else
{
if(searching_mode){
TEXT_SetText(TextWin[1], "Error!,Retry again");
}
Search_progress =0;
task1_ShowSearchingProgress(0);
k = (p_dogg->tree.sizeTree+(SYNC_BLOCK_SIZE-1))/SYNC_BLOCK_SIZE;
k += (p_dogg->hunt.sizeTree+(SYNC_BLOCK_SIZE-1))/SYNC_BLOCK_SIZE;
k += (p_dogg->favorite.sizeTree+(SYNC_BLOCK_SIZE-1))/SYNC_BLOCK_SIZE;
Progress_PercentTime = (k * SYNC_TransTime)/100;
if(Progress_PercentTime==0)Progress_PercentTime=1;
flash_erase_nbytes(address_tree(p_dogg->reg_index, EXPT_HUNTS_OFFST),p_dogg->hunt.sizeTree);
last_progress=0;
block_index = 0;
send_sync_cmd(p_dogg->ID,SYNC_CMD_ExpertHunt,0);
task1_delay = SYNC_TransTime+20;
task1_state = TaskSTATE_WaitExpertHunt;
}
}
else
{
task1_state = TaskSTATE_SyncHuntOk;
}
break;
case TaskSTATE_SyncHuntOk:
p_dogg = &dogg[dogg_index];
task1_state = TaskSTATE_SYNC_Favorate;
break;
///////////////////////////////
case TaskSTATE_SYNC_Favorate:
error_count =0;
p_dogg = &dogg[dogg_index];
if(p_dogg->favorite.sizeTree == 0){
if(*(u16*)(FLASH_DATA_STARTADDR + p_dogg->favorite.DirTree)!=0xffff){
flash_erase_nbytes(address_tree(p_dogg->reg_index,FAVORITE_OFFSET),2);
}
task1_state = TaskSTATE_WaitSyncNextDogg;
break;
}
else if(check_flash_CRC(&p_dogg->favorite) == SUCCESS){
task1_state = TaskSTATE_WaitSyncNextDogg;
break;
}
new_doggs =1;
flash_erase_nbytes(address_tree(p_dogg->reg_index,FAVORITE_OFFSET),p_dogg->favorite.sizeTree);
last_progress=0;
block_index = 0;
send_sync_cmd(p_dogg->ID,SYNC_CMD_Favorite,0);
task1_state = TaskSTATE_WaitFavorite;
task1_delay = SYNC_TransTime+20;
break;
case TaskSTATE_WaitFavorite:
if(flag_ack == ACK_SYNC_TheEnd){
task1_state = TaskSTATE_CheckSyncFav;
}
else if(flag_ack == UART_COMMAND_Sync){//下一个block
last_progress=0;
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_Favorite,++block_index);
task1_delay = SYNC_TransTime+20;
}else if(task1_delay) {//等待时间
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
}else if(last_progress > 5){//失败
dogg[dogg_index].MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}else {//没收到
last_progress++;
send_sync_cmd(dogg[dogg_index].ID,SYNC_CMD_Favorite,block_index);//重做
task1_delay = SYNC_TransTime+20;
}
break;
case TaskSTATE_CheckSyncFav:
p_dogg = &dogg[dogg_index];
if(p_dogg->favorite.sizeTree == 0)
{
p_dogg->favorite.CRCTree=0;
task1_state = TaskSTATE_SyncFavOk;
}
else if(check_flash_CRC(&p_dogg->favorite) != SUCCESS)
{
if(++error_count > 2){
p_dogg->MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}else
{
flash_erase_nbytes(address_tree(p_dogg->reg_index,FAVORITE_OFFSET),p_dogg->favorite.sizeTree);
if(searching_mode){
TEXT_SetText(TextWin[1], "Error!,Retry again");
}
Search_progress =0;
task1_ShowSearchingProgress(0);
k = (p_dogg->tree.sizeTree+(SYNC_BLOCK_SIZE-1))/SYNC_BLOCK_SIZE;
k += (p_dogg->favorite.sizeTree+(SYNC_BLOCK_SIZE-1))/SYNC_BLOCK_SIZE;
Progress_PercentTime = (k * SYNC_TransTime)/100;
if(Progress_PercentTime==0)Progress_PercentTime=1;
last_progress=0;
block_index = 0;
send_sync_cmd(p_dogg->ID,SYNC_CMD_Favorite,0);
task1_state = TaskSTATE_WaitFavorite;
task1_delay = SYNC_TransTime+20;
}
}
else
{
task1_state = TaskSTATE_SyncFavOk;
}
break;
case TaskSTATE_SyncFavOk:
p_dogg = &dogg[dogg_index];
task1_state = TaskSTATE_SyncTree;
break;
////////////////////////////
case TaskSTATE_SyncTree:
error_count =0;
p_dogg = &dogg[dogg_index];
if(check_flash_CRC(&p_dogg->tree) == SUCCESS){
task1_state = TaskSTATE_WaitSyncNextDogg;
break;
}
flash_erase_nbytes(address_tree(p_dogg->reg_index,TREE_OFFST),p_dogg->tree.sizeTree);
k += (p_dogg->tree.sizeTree+(SYNC_BLOCK_SIZE-1))/SYNC_BLOCK_SIZE;
last_progress =0;
block_index = 0;
send_sync_cmd(p_dogg->ID,SYNC_CMD_Tree,0);
task1_delay = SYNC_TransTime+20;
task1_state = TaskSTATE_WaitSyncTree;
break;
case TaskSTATE_WaitSyncTree:
p_dogg = &dogg[dogg_index];
if(flag_ack == ACK_SYNC_TheEnd){
task1_state = TaskSTATE_CheckSyncTree;
}
else if(flag_ack == UART_COMMAND_Sync){//下一个block
last_progress=0;
send_sync_cmd(p_dogg->ID,SYNC_CMD_Tree,++block_index);
task1_delay = SYNC_TransTime+20;
}else if(task1_delay) {//等待时间
task1_ShowSearchingProgress(Search_progress/Progress_PercentTime);
}else if(last_progress > 5){//失败
p_dogg->MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
}else {//没收到
last_progress++;
send_sync_cmd(p_dogg->ID,SYNC_CMD_Tree,block_index);//重做
task1_delay = SYNC_TransTime+20;
}
break;
case TaskSTATE_CheckSyncTree:
p_dogg = &dogg[dogg_index];
if(p_dogg->tree.sizeTree == 0)
{
p_dogg->tree.CRCTree = 0;
task1_state = TaskSTATE_SyncTreeOK;
}
else if(check_flash_CRC(&p_dogg->tree) != SUCCESS)
{
if(++error_count > 2)
{
p_dogg->MemState |= Dogg_ERROR_MASK;
task1_state = TaskSTATE_WaitSyncNextDogg;
break;
}
flash_erase_nbytes(address_tree(p_dogg->reg_index,TREE_OFFST),p_dogg->tree.sizeTree);
if(searching_mode){
TEXT_SetText(TextWin[1], "Error!,Retry again");
}
task1_ShowSearchingProgress(0);
Search_progress =0;
k = (p_dogg->tree.sizeTree+(SYNC_BLOCK_SIZE-1))/SYNC_BLOCK_SIZE;
Progress_PercentTime = (k * SYNC_TransTime)/100;
if(Progress_PercentTime==0)Progress_PercentTime=1;
last_progress =0;
block_index = 0;
send_sync_cmd(p_dogg->ID,SYNC_CMD_Tree,0);
task1_delay = SYNC_TransTime+20;
task1_state = TaskSTATE_WaitSyncTree;
}
else
{
task1_state = TaskSTATE_SyncTreeOK;
}
break;
case TaskSTATE_SyncTreeOK:
new_doggs = 1;
p_dogg = &dogg[dogg_index];
task1_state = TaskSTATE_WaitSyncNextDogg;
break;
//////////////////////////////////
case TaskSTATE_WaitSyncNextDogg:
p_dogg = &dogg[dogg_index];
if(!(p_dogg->MemState & Dogg_ERROR_MASK))p_dogg->MemState |= Dogg_SYNCED_MASK;
if(searching_mode == SearchMode_startup || searching_mode == SearchMode_SyncAll)
{
while(++dogg_index < Doggs_List_MAX)
{
if(dogg[dogg_index].doggtype>= TOP_DOGG && dogg[dogg_index].doggtype <=TRIPLE_DOGG)
{
task1_state = TaskSTATE_TurnOnDevice;
return;
}
}
}
if(new_doggs){
new_doggs=0;
save_RegistDoggs_in_flash();
}
if(searching_mode == SearchMode_startup){
task1_state = TaskSTATE_READY;
}else if(searching_mode == SearchMode_SyncAll){
PROGBAR_SetValue(ProgWin, 100);
TEXT_SetText(TextWin[1],"All synchronized");
if(menu_page == MENU_SyncSettings)
{
SyncSettings_page(0);
LISTBOX_SetSel(ListItem,ListIndex[MENU_SyncSettings]);
}
searching_mode = 0;
icon_refresh(1);
task1_delay = 500;
task1_state = TaskSTATE_SyncDisplay;
}else if(searching_mode == SearchMode_SyncOne){
PROGBAR_SetValue(ProgWin, 100);
TEXT_SetText(TextWin[1],"synchronized");
if(menu_page == MENU_SyncSettings)
{
SyncSettings_page(0);
LISTBOX_SetSel(ListItem,ListIndex[MENU_SyncSettings]);
}
searching_mode = 0;
icon_refresh(1);
task1_delay = 500;
task1_state = TaskSTATE_SyncDisplay;
}else{
searching_mode = 0;
task1_state=TaskSTATE_NORMAL;
}
break;
case TaskSTATE_SyncError:
dogg_index = 0;
last_progress =0;
break;
case TaskSTATE_READY:
GUI_EndDialog(first_window, 0);
main_window = CreateWindow();//主窗体
set_icon_backcolor(0);
menu_page =MENU_home;
speaker=0;
timer_count_start=1;
key_code=KEY_NONE;
task1_state=TaskSTATE_NORMAL;
homepage();
searching_mode = 0;
break;
/////////////////
case TaskSTATE_GoFoundDogg:
searching_mode = SearchMode_goFound;
task1_state = TaskSTATE_SearchFinished;
break;
case TaskSTATE_AddFoundDogg:
searching_mode = 0;
task1_state = TaskSTATE_SearchFinished;
break;
case TaskSTATE_SyncDisplay:
if(task1_delay)return;//等待,显示搜索结果0.5秒
SyncSettings_page(0);
LISTBOX_SetSel(ListItem, ListIndex[MENU_SyncSettings]);
task1_state = TaskSTATE_NORMAL;
break;
case TaskSTATE_MenuSYNC_start:
k = LISTBOX_GetSel(ListItem);
if(k == 0)//sync now
{
dogg_index=0;
searching_mode =SearchMode_SyncAll;
task1_state = TaskSTATE_CheckDogg;
}
else //dogg
{
dogg_index = k-1;
searching_mode =SearchMode_SyncOne;
task1_state = TaskSTATE_TurnOnDevice;
}
break;
///////////////////
case TaskSTATE_TESTBAUDRATE:
if(task1_delay)return;
setup_RF915(test_baudrate,0);
task1_delay=RF_TEST_StartDelay2;
task1_state = TaskSTATE_TEST915;
break;
case TaskSTATE_TEST915:
if(test_flag_testresult)
{
test_flag_testresult = 0;
display_testresult();
task1_delay=2;
}
if(!RF915_AUX)return;
if(task1_delay==0)
{
RF_test_send_frame();
task1_delay=RF_TEST_CYECLE;
}
break;
case TaskSTATE_FccBAUDRATE:
if(task1_delay)return;
setup_RF915(test_baudrate,1);
task1_delay=RF_TEST_StartDelay2;
task1_state = TaskSTATE_TEST915FCC;
break;
case TaskSTATE_TEST915FCC:
if(task1_delay)return;
Remote_FCC_test_RF915();
break;
case TaskSTATE_DEBUG:
TEXT_SetText(TextWin[1], "Debug ");
GUI_Delay(1000);
if(searching_mode==SearchMode_startup){
searching_mode =0;
task1_state = TaskSTATE_READY;
}else
{
task1_state=TaskSTATE_NORMAL;
}
break;
}
}
void MainTask(void)
{
#ifdef FIND_REGISTED_ONLY
u8 k;
#endif
dogg[0].main_volume=dogg[1].main_volume=dogg[2].main_volume=DEFAULT_VOL;
adc_bat=ADC_Get_aveg(ADC_Channel_12,10);//(0~4095);
WM_SetCreateFlags(WM_CF_MEMDEV);
GUI_Init();
BUTTON_SetDefaultSkinClassic();
WIDGET_SetDefaultEffect(&WIDGET_Effect_None);
#ifdef KEYTIME_POWERON
delay_ms = KEYTIME_POWERON;
while (delay_ms)
{
if((GPIO_ReadInputData(GPIOB) & GPIO_Pin_4) !=0 )//enter key
{
BackLight_OFF();
SYSTEM_POWER_OFF();
while(1);
}
}
#endif
key_code = KEY_NONE;
task1_state = TaskSTATE_On;
first_window = CreateFRM0();//开机画面
GUI_Delay(100);
flag_power=2;
set_brightness(brightness);
SYSTEM_POWER_ON();
setup_RF915(RF_BAUDRATE,0);
key_code = KEY_NONE;
menu_page = MENU_GoPage;
task1_state = TaskSTATE_CheckDogg;
#ifndef FIND_REGISTED_FIRST
for(k=0;k < Doggs_REG_MAX;k++)
{
if(registed_dogg[k].doggtype != 0xff)goto TASK_CHECK;
}
TEXT_SetText(TextWin[0], "Welcome to The Dogg Net\nGame Caller System");
TEXT_SetText(TextWin[1], "To start hunting\nplease register your doggs");
LISTBOX_SetString(ListItem, "Go!",0);
WM_ShowWindow(ListItem);
task1_state = TaskSTATE_GO;
TASK_CHECK:
#endif
while(1)
{
task1_progress();
polling();
KEY_Handler();
if(flag_power ==2)
{
GUI_Exec();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化