From nobody Sat Nov 15 03:44:32 2025 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4d7g6s4Dqhz6Gyy2 for ; Sat, 15 Nov 2025 03:51:49 +0000 (UTC) (envelope-from freebsd-hackers-freebsd-org952@ketas.si.pri.ee) Received: from mail.ketas.si.pri.ee (d004-fea2-0bff-021e-13e8-8437-07d0-2001.dyn.estpak.ee [IPv6:2001:7d0:8437:13e8:21e:bff:fea2:d004]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4d7g6r5b1Qz49Y0 for ; Sat, 15 Nov 2025 03:51:48 +0000 (UTC) (envelope-from freebsd-hackers-freebsd-org952@ketas.si.pri.ee) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=ketas.si.pri.ee header.s=ketas-si-pri-ee-20240416002854-4096 header.b=Z55ZqVQc; dmarc=pass (policy=reject) header.from=ketas.si.pri.ee; spf=pass (mx1.freebsd.org: domain of freebsd-hackers-freebsd-org952@ketas.si.pri.ee designates 2001:7d0:8437:13e8:21e:bff:fea2:d004 as permitted sender) smtp.mailfrom=freebsd-hackers-freebsd-org952@ketas.si.pri.ee X-Original-To: elrond@phoe.frmug.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ketas.si.pri.ee; s=ketas-si-pri-ee-20240416002854-4096; t=1763178274; bh=xB8e5YOxdrRvEhR+U3NnIhED7PUI0mvhV7Goseu46AM=; h=Date:From:To:CC:Subject:In-Reply-To:References; b=Z55ZqVQc9mBLIfWf6KfKWG2RhOR5vxBRK7G21cb45Yh/Jk8kLKW7OzsM2rj8RYFgd 5ELA/AMclSeH8+i9iy2WxKsETQt4VB55fUVY8ekcXCjHFqit6LxnB5u8wCjxyGugRj tMZbOySAUFw3djFlfoWaYjrbklBYGv5VwaeVu7CDKUqYRSL0hYg9GbFqw/VofAF487 StwRPf1ePyjflPGxgxpT0ko4UEJHfZr441SX80CNAMuAgDrCu4K9Z+jwodzj3UlSPs tSc76wVQbkfm5Hh2/1sMMJIZ0YOz3050uAAK4Zjoc54weVeeZooA3r6JdZsALwy/Mf XlCuCBmZT4Gn8NjMX2RADF9VNFJEraZtwORr18CXrYgwUBQijmXEBqKf0iTUu7IPTk 1aTRP6riD2tQshI1V6LYogB1wD0NbsvpbQ5/JGiRH+OarkLnJa81mFPZJwgjkqGD/S NRJOhku8/yA73DEaWD646sXmn7/G0keL3tak7hlS4vQKioEVXGBj8aNAxK84y6dnc3 3yE9dDTSN7Q3J0EL/5sWg6DD+P4H2/GhDje5VAvLMokO1QzcWyNnDs3wxMmd/G55zV pVbqFp8Eh37/b+bqu+pgW1jwJ2T226orCT7tHjf3JAiIVySoYvKuIaQ0ChirShsIUt ZoENOKkugqS5fByxBVPhyVHQ= X-Original-To: freebsd-hackers@freebsd.org Received: from ehlo.thunderbird.net (0115-0000-0000-0000-13c8-8437-07d0-2001.dyn.estpak.ee [IPv6:2001:7d0:8437:13c8::115]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ketas.si.pri.ee (Postfix) with ESMTPSA id 972DA5BFC17; Sat, 15 Nov 2025 05:44:33 +0200 (EET) Date: Sat, 15 Nov 2025 05:44:32 +0200 From: Sulev-Madis Silber To: Bertrand Petit CC: freebsd-hackers@freebsd.org Subject: Re: addressable led driver User-Agent: K-9 Mail for Android In-Reply-To: <20251114165655.GL28154@memo2.memo.frmug.org> References: <4DE06290-81C0-4D21-8919-5A39B1DB3949@dons.net.au> <20251114165655.GL28154@memo2.memo.frmug.org> Message-ID: <0146E899-98E1-4582-9DE5-48251695E435@ketas.si.pri.ee> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=----YDXK3PT53ST1YG9Y6H0JR7R44WPHEB Content-Transfer-Encoding: 7bit X-Spamd-Bar: +++ X-Spamd-Result: default: False [3.87 / 15.00]; HFILTER_HOSTNAME_5(3.00)[d004-fea2-0bff-021e-13e8-8437-07d0-2001.dyn.estpak.ee]; MIME_BAD_ATTACHMENT(1.60)[c:text/x-csrc]; MIME_BASE64_TEXT_BOGUS(1.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.98)[-0.978]; NEURAL_SPAM_LONG(0.94)[0.943]; DMARC_POLICY_ALLOW(-0.50)[ketas.si.pri.ee,reject]; R_SPF_ALLOW(-0.20)[+ip6:2001:7d0:8437:1300::/56]; R_DKIM_ALLOW(-0.20)[ketas.si.pri.ee:s=ketas-si-pri-ee-20240416002854-4096]; ONCE_RECEIVED(0.20)[]; MIME_BASE64_TEXT(0.10)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-csrc]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; GREYLIST(0.00)[pass,body]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[ketas.si.pri.ee:+]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; HAS_ATTACHMENT(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:3249, ipnet:2001:7d0::/32, country:EE]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: 4d7g6r5b1Qz49Y0 ------YDXK3PT53ST1YG9Y6H0JR7R44WPHEB Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On November 14, 2025 6:56:55 PM GMT+02:00, Bertrand Petit wrote: >On Fri, Nov 14, 2025 at 06:21:12AM +0200, Sulev-Madis Silber wrote: >> so i did read the chatgpt driver > > Drop those bots, they are producing crap; use your own judgement >instead, make errors, learn from them=2E oh it's a tool=2E why i went there, was because i hated the amount of info= rmation i had to process in this case, i was surprised=2E seems like it was generated from drivers= =2E but from all of them=2E in 12s i already said probably going to use real brain btw that's second time i tried to generate code from there=2E many others = use it all the time they say=2E to which i say what's the joy, quality and = control anyway, why that way is because i can't read all that=2E maybe i found wro= ng information=2E maybe kernel drivers are actually hard=2E reading fat boo= ks also don't work for me=2E reading drivers wears me out=2E maybe talking = others helps=2E tried to ask in several irc channels if anyone wants to exp= lain drivers also didn't get anyone's attention yet i did write ws2801 driver from scratch so i don't really have problems wit= h understanding that part the problem is that my favorite language, perl doesn't just allow me to do= nanosecond precision i actually tried to pwm dim a led from perl too=2E this tool all the cpu i= n bbb and as fast as it went, still looked as if i could see it=2E i probab= ly was seeing it but turning to other languages and platforms is very hard=2E maybe if you = have been in uni, you find it easy=2E i did all this on my own=2E i didn't = go there because i hate people but amount also looks too much at once=2E i = had this entire life=2E schools probably actually teach things in a way tha= t not everybody gets it anyway=2E=2E=2E > >> looks like drivers i read (where this info probably came from, includin= g > spkr i didn't look yet), character device for data, ioctl for config, > bitbanging and sleep that i don't really get (binary math and cpus are = hard) > > Binary math is not as complicated as it sounds, it is, at least not as >difficult as CPU programming=2E Directly programming CPUs is a difficult = talk >because before being able to do anything you need to absorb at once a lar= ge >quantity of informaiton=2E yeah and what if i can't do that, i installed 4=2E6=2E still can't do it n= ow=2E went into embedded in 2013, still hard nowadays=2E electronics i did = pretty much entire life, that's bit better=2E i'm 42=2E unless we extend li= fe, i die before understanding of this=2E just can't with trial and error, i was able to write lpt control program once=2E i ha= ted the way that port was represented as address while i wanted to control = pins i had to use all << >> | & operators in c because i just didn't get how th= ey actually modify bits which then cause hw to turn transistors on and off,= resulting in voltage on port pins meh i once had like gf who explained cpus to me but she ran away as i wasn= 't able to constantly deal with her or people at all > >> soc is h3, i don't know how well it keeps timings=2E it's ability to ke= ep >> actual wall clock time without is bs=2E or is it it's rtc > > Date and calendar computations is a set of hard problems; timekeeping >is a very hard problem sitting on the frontier of electronics and physics= =2E For >dates, use external proven libraries, for the second, don't sleep, use >hardware timers or those provided by an operating system=2E forgot the "without ntp" here=2E but yeah, but what if i don't get it? > >> there's always option to go dedicated uc way and use (usb) uarts or usb >> direct > > I don't know the problem you're trying to solve, you sound like >chasing several foxes at the same time=2E Is it an ad-hoc development or = shall >it be generic? For the ad-hoc route, a microcontroller is probably the ea= siest >solution=2E There are tons of libraries tackling the adressable led strip= s=2E Have >a look at this introductory resource: > > > Make the microcontroller drive the LEDs *and* run the animations=2E >Command the microcontroller actions from the main CPU with small infreque= nt >messages=2E i don't like the small messages=2E this would mean that it's fixed inside = uc=2E and you at best write that in c=2E at worst in asm, which is horribly= hard to get as you don't have any visible tools there=2E it's as if you ha= ve atoms when you need screwdriver=2E i bet you can make screw turning with= them if i go uc way i would need to put a dynamic wrapper there that i can comm= and from "actual computer" i understand even a puny cpu nowadays should be able to generate data in speeds that hu= man eye misses=2E especially considering my screen resolution is like 32*32= ? existing led projects are weird too=2E i don't want to use existing things= as there's no fun taking code, flashing it and looking results many run like displays and so on i mean you can get dmx controllers for leds, but that's not fun either it's not fun to poorly translate my ideas to c, flash into uc, see result > >> but what are realistic results i could get from direct control? i'm awa= re that somehow spi and dma could help > > Use whatever is supported by the microcontroller you choose, RS232, >RS485, I2C, SPI, etc=2E > >> i mean i could run out of real hw spis but those signals don't travel t= hat >> far anyway so maybe it's enough=2E my idea is not driving screen amount= of >> leds right now > > I2C is a bus through which you can talk to several to several slaves, >some SPI slaves can be daisy chained=2E Each slave microcontroller can dr= ive >several hundred LEDS=2E The limit would then be how well you synchronize = the >microcontrollers against each other=2E > >> if cpu speed changing would make it bad, could i lock it? would that ca= use >> too much heat? > > Again, don't sleep, halt instead and use hardware timers=2E > so, could i get some out of fbsd or not? i already know uc's can do it=2E and i already know existing, eg, artnet p= roxys exist seems too much for me i want to do my own=2E unsure how=2E probably works=2E would work but my idea was to do that direct if i use uc, this isn't much of a fbsd problem anymore unsure what's generic or ad hoc too, just want to play with those things probably need to use faster serial than 115 too anyway i wanted to skip this rube goldberg of serials and uc's and all tho= se and go direct os control but now i have issue=2E this is not realtime actually i don't know how much i need=2E how accurate a bitbang would be= =2E is nanosecond a issue? if yes, i can't use cpu indeed i also totally hate how everything in cpu is somehow some "address"=2E whi= le i want to control some individual pin electrically unsure how i sync multiple uc too, actually=2E i assume=2E and i have trie= d, that i should be able to send data via ethernet, via non-realtime os, ou= t to hw fast enough that eye doesn't notice it how many i need, no idea i plan to try out but the original idea and question was, can you use fbsd and armv7 h3 to b= itbang a ws2812 protocol? if no, no problem, i take a uc=2E if yes, how muc= h, how fast? i looked into gpio section of kernel and found several bitbang drivers=2E = many seem fast=2E unsure what hw they need but i don't recall many amd64 ma= chines with user gpio pins=2E so it must be for rpi class machines so precision is there probably if i go uc way, i want to be able to tell uc everything i want dynamically just like with future fbsd driver i don't know how=2E i don't want to program hw=2E i don't want that hard c= ode=2E i find it sucks=2E it's too hard=2E it pisses me off=2E i want to ma= ke code so i don't need to touch it again=2E possibly need others because i= can't figure it out that's why i got llm involved at all=2E i was unable to read out from driv= ers, google, man, what i need i know how that protocol works, it's in pdfs i want to send that spec to driver or uc along with data the wled kind of does that but i want my own way=2E it's not that hard eve= n also i realize there are different "sleeps"=2E but i don't want to know th= em either=2E that much=2E it's mindboggling to get=2E all i want is nonacti= on for certain time=2E how cpu does that efficiently, no idea=2E chatgpt pr= oposed asm pause=2E you tell me if it's bad or not=2E tried to google too= =2E seems good? bad? unsure, maybe wasn't like that in those other drivers it's also very hard to read drivers=2E i need to know c as well as all the= other function names in order to read that like english=2E it took me ages= to figure out the totally assbackwards way the drivers actually toggle a p= in=2E it was complete wtf=2E i don't get any of this and addresses again=2E sorry=2E i hate this=2E all the date about cpus is = very hard and i can't read a single page of that i don't know how many years it would take for me=2E i feel like i die firs= t=2E looking the drivers, i could probably make my own driver which i then = could share to get reviews=2E likely this gets it better as i don't get any= of this reading spkr was similarly hard=2E like don't get it at all=2E too hard i don't know how to make my task happen i just want to run things=2E except it's not how i want getting leds is easy actually maybe not all i know is that led has a ic in it which turns short and long pulses in= to bits it then stores=2E it stores what it needs and rest it forwards out= =2E there's extra reset pulse that's about 50 times longer, that's when it = takes bits and puts them to it's second part, where it pwms the leds=2E sup= posedly it's all hw=2E which is fun=2E actually hw is sw and sw is hw so yo= u can make this all happen in hw if you want=2E supposedly that led chip is= elaborate shift register=2E but i don't even know what that is=2E i bet it= shifts bits i also don't get gates=2E i get it's circuit of transistors transistor is bit easier=2E it's a switch=2E i don't like to think how qua= ntum physically it works=2E i find it hard actually i started coding on my own, i just used mirc=2Eexe, it hard high = level scripting language in it=2E so i learned that=2E didn't took any clas= s on hw=2E and in 1999 it probably was too late as computers ran high level= code already anyway, i know how it it works lets see: bit_0() { gpio_on; sleep 350ns; gpio_off; sleep 800ns; } bit_1() { gpio_on; sleep 700ns; gpio_off; sleep 600ns; } reset() { sleep 50us; } while() { } whatever it's all so complex=2E i need to turn 1 byte into 8 bits=2E which is hard = to get if you know that byte is number from 0 to 256 or 00 to ff in hex and 128 is half of it anyway i hate it all, i hate computers, i hate binary, fuck this i never learn any of that=2E but that was not the point here even=2E i jus= t wanted to simply send those pulses but apparantly i can't send it but i need to massage hw the right way so it's prohibitely expensive in my brain to comprehend the sheer amount t= o shit i need to understand in order to do this one simple task and yes, the higher level the code is, the easier it is to read=2E because= you can simply command the computer to do the task so no idea how to do this=2E those existing led projects look bad=2E most = use wifi, i would need extra ap for that, etc=2E and who needs complex, hig= h latency or insecure things if i want arduino, i would have used it=2E but i find it boring=2E or hard= or=2E or fixed=2E or whatever i just want to run code=2E on leds=2E i connect hw up=2E tell it what to d= o, it does it unfortunately i first need to make something below this code before i can = run the "real" code and that's very hard=2E or i don't know it's also like fun to learn but it gets hard fast=2E that's why i hated ev= en school math it's also harder if i don't get it and i don't, i probably spend reading all that until i actually die books won't work, reading drives won't work=2E unsure what works=2E it jus= t gets me all pissed and nothing good happens from what i somehow see, sleeping below 1us is next level task in kernel? = i mean that is short time after all oh well=2E but yeah, flashing fixed code into uc won't work for me has to be better anyway, of course if uc is only option, i will use uc=2E but hell with con= necting to it=2E and it ALSO needs code=2E it won't just execute my task to= turn voltages on and off i bet that's why whole arduino happened too=2E people don't like to do har= d tasks=2E i don't like arduino because it makes c harder than it actually = is, tho so i don't know what i do=2E i probably try anyway i also spent ages of cursing on how to set gpioths and ow pins via fdt ove= rlays=2E to me it was super frustrating=2E it's as long and complex path as= it can get actually there's nothing human readable in computers=2E but humans don't w= ork in binary=2E at least easily so yeah i hate it all=2E i don't understand it=2E i'm unable to find right= information=2E sometimes i find it=2E no existing ones seem to work=2E i d= on't know how others did it the sleep, pause, delay, noop, whatever it is that stops action for time p= eriod, it just causes me to have breakdown yet drivers do it that ths is much slower i see=2E in ms, while leds do us and ns eh all i know is that iirc gpioths driver writer said that it should be possi= ble to drive leds there anyway, no idea what i will do=2E all is hard=2E existing is wrong=2E need= to make own so it's better right and fits me=2E but i can't=2E i don't kno= w how=2E all i have is some fet in some hw that i need to turn on and off i= n nanosecond precision in order to send data=2E i get that=2E on=2E wait=2E= off=2E wait=2E repeat just how to do that is wtf so yeah seems like i can't read any driver because i don't get it gpioths=2Ec seems easiest but it doesn't have the sub 1us anyway i don't have honest idea how to make it right=2E anything i read ab= out big or small cpus quickly overwhelms me and i haven't found anything th= at doesn't i understand that sleep is wrong term but to me sleep is a period of wait just like sleep(1) sleeps=2E sleep 1 sleeps for 1s=2E i haven't looked how= it actually "sleeps"=2E same in kernel=2E i don't know how kernel "sleeps"= while also "running" in fact i don't even know what kernel IS=2E i consider it an elaborate whi= le(1) { } loop that somehow has "subcode" "programs" in it=2E but it also h= as like interrupts which i don't get i looked what ccc guys did for r0ket and it was a bit easier but still har= d anyway, i don't get it i hope i don't need whole hw course for just gpio pin control i don't know where the information i need is=2E often it's in form i don't= get=2E i mean most of fbsd manpages are very well written anyway i don't get this all at all now might as well give up at least in bigger computer it feels better=2E you can use actual tools=2E= run actual code=2E without all that hw=2E if it were slow task, it would b= e already working just look into gpioctl -l, it even has names in case of h3=2E even if no, = it would be possible to find which is which once you find it, it's easy, then you find a hw pin and you could even write shell script for toggling that then comes the big issue=2E you can't shell script the ws2812 it's too big and complex os there in uc you can do that but you don't have tools anymore=2E the tools you ha= ve are so primitive that you don't even recognize them=2E but you can have = precise control eh i hate that so i had idea=2E even if this only controls small amount of leds=2E to mak= e a driver=2E so i can shell script a ws2812=2E tell it pin, timings, and j= ust give it data if os kernel really sucks at it, i would need to tell uc it=2E actually th= e wled project is pretty much it=2E but i want my own i also attached the files that the mechanical marvel of the ten thousand g= pus (or fuck knows which *pu's), created for me=2E it builds=2E it looks li= ke normal driver for me=2E had to fix wtf's and probably it has many more files here are direct tho, without any fixes but you have to admit that ability to read *AND* compile gpu "pipe dream" = is wonderful=2E even if it sucks also it probably got it from human written fbsd drivers i was curious if it can i have no idea why char dev was created=2E or ioctls=2E didn't ask if that was wrong, well what's right then? i mean if i could, i could write driver on my own=2E but i can't=2E i don'= t understand it all i give up now, of course, i don't know if that approach works=2E god knows where it = eve came from=2E it's not in fbsd drivers i saw=2E linux drivers? nowhere? = that's the power of llm as well=2E creates thing from thin air=2E it has no= "logic" i mean i agree i should make driver myself=2E just like all other code i m= ade=2E but it's too complex=2E maybe kernel driver interface itself needs i= mprovement=2E maybe it can't be improved=2E maybe i will learn it, maybe i = won't in any way, i don't feel like any learning has been happening and i only g= et angrier i looked into drivers and couldn't figure out the one which i can base my = new code upon and in uc it's also hard=2E have to receive it somehow from some port, the= n send out=2E all at same time=2E i hate to think of memory and stuff there= too that's why i wanted to skip all that hard work but maybe i can't so yeah, in sbc soc it's easier, it's also complex=2E costs 10+ times the = uc=2E has poor timing=2E but has all my familiar tools whatever=2E can't blame me too much for trying to move freely in big room,= instead of small uc box where i as if constantly hit myself to walls and h= urt myself maybe people get even worse on this=2E who knows if i have spent like large parts of my life to learn this, i don't think i= can ever if i complete my driver i'm like phewww i hope i never need to touch it ag= ain and can return to my normal life of doing things i don't know, i did ask from led lighting communities too, they didn't get= me either=2E but there most people know even less code i want some middle ground here i'm not that stupid either i want to run most of stuff in "actual machine"=2E which are small and che= ap now i'm not arguing if it physically can't be done=2E but i hope it can the bbb pru idea is nice but bbb seems to be in sorry state now and new 64= bit ti socs don't have support yet iirc? price did fall tho or i could do soc+uc but i don't like to code, and i don't like to disassmble hw to flash it=2E= it has to be possible from os=2E one could view this as extra realtime cor= e anyway i don't even know what realtime even is=2E i view it as something t= hat works fast and doesn't jitter around and skip a beat the ti pru looks cool tho=2E i did read it shares memory and you can put c= ode there somehow=2E unsure how=2E it has no flash so it somehow takes code= from host, live separate uc is harder=2E more secure but i don't really see someone hackin= g me that way=2E they have physical access anyway so yeah, i get that you could connect all uc pins to soc and then hopefull= y you can reset and flash it i also don't like to disassemble things for upgrades, that part works alre= ady unsure what i'll do=2E the beagle stuff is just one hw too and i want to h= ave more diffrent hw's maybe so i don't know, maybe soc+uc is best if just soc sucks i mean this is hobby now but who says hobby can't be professional quality anyway i hate the hw=2E i actually tried to create hw from chatgpt too, fo= r fun it actually wasn't possible before=2E but now you can hallucinate yourself= a non-working pcb that job is hard too=2E i mean i know how my circuit would look like=2E el= ectrically i would have working schematic in my head but now comes the hard= part of making it i wish i could just say, this wire goes here, that one goes there, this pr= otection diode goes here, and so on=2E make it into 3d model and i'll take = a look if it's ok to me then make it=2E i don't want to draw schematics, route=2E make gerbers, gc= ode, whatever=2E i just want the object, working same with led driving software i don't want to write driver at all i just want to control it=2E i have parameters, they are supposed to work,= so i want to try=2E unfortunately i can't as i have the tool somewhat miss= ing oh and turnkey is too boring actually my ws2812 / sk* whatever string came with cheap bt controller and= app but seems like they wrote bad code or chose bare minimum uc, because i= see freq with my eyes to my knowledge, you can't see ws2812 i'm aware that there are faster ones with higher local pwm and also update= speed but i've seen displays running on ws2812 and it's probably controller issu= e so i don't know=2E original idea was kernel driver for single line and per= haps also clock+data leds you tell me how many could various hws drive=2E i hope answer is not 0 the uc way would be unfortunate but if it's needed, it would need to be se= amless=2E maybe some bootloader or loaded fw or code or whatever the visible result would be like running multicore or multi cpu machine, y= ou never mess with it, you don't flash the cpus, you don't code for them, c= ode just runs=2E on the below, i don't know how it works, way too hard=2E i= tried to get how smp works but i can't well probably could use existing components too=2E i mean i didn't write f= bsd either=2E but many of those are weird like, you need to define pins, hardcode led number, so on=2E who needs tha= t=2E even hardcode animations, not my idea, i want to change them i mean several places sell bridges too but those don't seem fun=2E like i = need more hacking=2E but not too much? whatever=2E it's either wrong or i don't it or what else if fbsd driver could work, that would be my favorite fun to think, maybe it could be implemented as kind of video output=2E eve= n tho it's slow and small tho, some of those projects actually treat them as screens=2E i've seen uc= 's synced via gpio's=2E never looked how it worked=2E that thing also recei= ved data from "computer" i mean uc's are not bad per se=2E but they are hard to use=2E always have = to use computer at side to run actual code in, etc lots of more freedom there, i can run every language i want in my usual things i often run shell+perl+c combinations with complexity g= oing from left to right but unfortunately if i put c into uc, it's much harder to "stdio pipe talk= " with it=2E this makes it difficult=2E don't like difficult or maybe in some other way i like i difficult because i don't like other w= ays maybe i did born too late no idea=2E used computer, immediately coding in = high level language=2E now i want to turn everything into similarly higher = level so i could understand it eh=2E that means showing "realtime" stuff aw= ay and just giving it the data but isn't that the idea of os too? if i touch the file abc, i don't want t= o perform tasks nor do i want to know how it actually gets all those bits i= nto fs and into physical device so maybe not that bad idea to abstract the hw i looked into gpiospi but unsure how it works=2E spi userland util exists = too but even that looks not up to my task i mean this is now spi at all and gpioths seema like 1000 times slower than i need=2E 1-wire is also slo= w=2E it's all slow the gpiospi and gpioiic feel like they must be faster but in that code, i = didn't even see how they sleep (call it whatever you want) so in the end i have nothing=2E=2E=2E ------YDXK3PT53ST1YG9Y6H0JR7R44WPHEB Content-Type: text/x-csrc; name=ws2812_freebsd_driver.c Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=ws2812_freebsd_driver.c; size=13253 LyoKICogd3MyODEyX2ZyZWVic2RfZHJpdmVyLmMKICogU2ltcGxlIEZyZWVCU0Qga2VybmVsIG1v ZHVsZSBza2VsZXRvbiBmb3IgZHJpdmluZyBXUzI4MTIoQikgIk5lb1BpeGVsIiBMRURzLgogKgog KiBUaGlzIGlzIGEgc3RhcnRpbmcgcG9pbnQgLyByZWZlcmVuY2UgaW1wbGVtZW50YXRpb24g4oCU IHRpbWluZyBmb3IgV1MyODEyIGlzCiAqIGV4dHJlbWVseSB0aWdodCBhbmQgZGVwZW5kcyBvbiBw bGF0Zm9ybSAoQ1BVLCBpbnRlcnJ1cHRzLCBjYWNoZXMpLiBGb3IKICogcmVsaWFibGUgcmVzdWx0 cyB5b3Ugd2lsbCB1c3VhbGx5IG5lZWQgdG8gdXNlIGhhcmR3YXJlIHBlcmlwaGVyYWxzIChTUEkr RE1BLAogKiBQV00gd2l0aCBETUEsIGRlZGljYXRlZCBMRUQgY29udHJvbGxlcikgb3IgcnVuIG9u IGEgcGxhdGZvcm0gd2hlcmUgeW91IGNhbgogKiBmdWxseSBkaXNhYmxlIGludGVycnVwdHMgd2hp bGUgYml0LWJhbmdpbmcuCiAqCiAqIFRoaXMgbW9kdWxlIGV4cG9zZXMgYSBjaGFyYWN0ZXIgZGV2 aWNlIC9kZXYvd3MyODEyIHRoYXQgYWNjZXB0cyBhIHNpbXBsZQogKiBzdHJlYW0gb2YgUkdCODg4 IGJ5dGVzIChHUkIgb3JkZXJpbmcgY2FuIGJlIHNlbGVjdGVkIHZpYSBpb2N0bCkuCiAqCiAqIEZl YXR1cmVzOgogKiAgLSBDb25maWd1cmFibGUgYmFja2VuZDogU1BJIChwcmVmZXJyZWQpIG9yIEdQ SU8gY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l6ZV90IGks IGo7CiAgICAvKiBjeWNsZSBjb3VudHMgZm9yIFQwSCwgVDFILCBhbmQgdG90YWwgcGVyaW9kIGlu IGN5Y2xlcyAqLwogICAgdWludDY0X3QgY190MGggPSAwLCBjX3QxaCA9IDAsIGNfcGVyaW9kID0g MDsKCiAgICBpZiAoY3ljbGVzX3Blcl91cykgewogICAgICAgIGNfdDBoID0gKHVpbnQ2NF90KSgw LjM1ICogKGRvdWJsZSljeWNsZXNfcGVyX3VzKTsKICAgICAgICBjX3QxaCA9ICh1aW50NjRfdCko MC43ICogKGRvdWJsZSljeWNsZXNfcGVyX3VzKTsKICAgICAgICBjX3BlcmlvZCA9ICh1aW50NjRf dCkoMS4yNSAqIChkb3VibGUpY3ljbGVzX3Blcl91cyk7CiAgICB9CgogICAgZm9yIChpID0gMDsg aSA8IGxlbjsgaSsrKSB7CiAgICAgICAgdWludDhfdCBiID0gZGF0YVtpXTsKICAgICAgICBmb3Ig KGogPSAwOyBqIDwgODsgaisrKSB7CiAgICAgICAgICAgIGludCBiaXQgPSAoYiAmIDB4ODApID8g MSA6IDA7CiAgICAgICAgICAgIGIgPDw9IDE7CgogICAgICAgICAgICBod19ncGlvX3NldChzYy0+ Z3Bpb19waW4sIDEpOwogICAgICAgICAgICBpZiAoY3ljbGVzX3Blcl91cykgewogICAgICAgICAg ICAgICAgaWYgKGJpdCkKICAgICAgICAgICAgICAgICAgICBkZWxheV9jeWNsZXMoY190MWgpOwog ICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgIGRlbGF5X2N5Y2xlcyhjX3Qw aCk7CiAgICAgICAgICAgICAgICBod19ncGlvX3NldChzYy0+Z3Bpb19waW4sIDApOwogICAgICAg ICAgICAgICAgLyogd2FpdCBmb3IgcmVzdCBvZiBwZXJpb2QgKi8KICAgICAgICAgICAgICAgIGRl bGF5X2N5Y2xlcyhjX3BlcmlvZCAtIChiaXQgPyBjX3QxaCA6IGNfdDBoKSk7CiAgICAgICAgICAg IH0gZWxzZSB7CiAgICAgICAgICAgICAgICAvKiBGYWxsYmFjazogdXNlIERFTEFZIG1pY3Jvc2Vj b25kcyAoYmFkIGFjY3VyYWN5KS4gKi8KICAgICAgICAgICAgICAgIGlmIChiaXQpIHsKICAgICAg ICAgICAgICAgICAgICBERUxBWSgxKTsgLyogfjF1cyBoaWdoICovCiAgICAgICAgICAgICAgICAg ICAgaHdfZ3Bpb19zZXQoc2MtPmdwaW9fcGluLCAwKTsKICAgICAgICAgICAgICAgICAgICBERUxB WSgxKTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgREVMQVko MCk7CiAgICAgICAgICAgICAgICAgICAgaHdfZ3Bpb19zZXQoc2MtPmdwaW9fcGluLCAwKTsKICAg ICAgICAgICAgICAgICAgICBERUxBWSgxKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAg fQogICAgICAgIH0KICAgIH0KICAgIC8qIHJlc2V0OiBob2xkIGxvdyBmb3IgPjUwdXMgKi8KICAg IGh3X2dwaW9fc2V0KHNjLT5ncGlvX3BpbiwgMCk7CiAgICBERUxBWSg2MCk7Cn0KCi8qIFNQSSBi YWNrZW5kOiBub3QgaW1wbGVtZW50ZWQgaGVyZSDigJQgcHJvdmlkZSBmdW5jdGlvbiBzaWduYXR1 cmUgZm9yIHBsYXRmb3JtCiAqIG93bmVycyB0byBpbXBsZW1lbnQuIEEgY29tbW9uIGFwcHJvYWNo OiBlbmNvZGUgZXZlcnkgV1MyODEyIGJpdCBhcyAzIFNQSQogKiBiaXRzIChvciBzaW1pbGFyKSBh dCBhIHN1aXRhYmxlIFNQSSBjbG9jayAoZS5nLiwgMi40TUh6IG9yIDNNSHopIGFuZCBzZW5kCiAq IHZpYSBTUEkgd2l0aCBETUEuICovCnN0YXRpYyBpbnQKd3MyODEyX3NlbmRfc3BpKHN0cnVjdCB3 c19zb2Z0YyAqc2MsIGNvbnN0IHVpbnQ4X3QgKmRhdGEsIHNpemVfdCBs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b3RlKSwgdWlvLT51aW9fcmVzaWQpOwogICAgICAgIGVycm9y ID0gdWlvbW92ZShzYy0+YnVmICsgd3JvdGUsIHRvY29weSwgdWlvKTsKICAgICAgICBpZiAoZXJy b3IpIHsKICAgICAgICAgICAgbXR4X3VubG9jaygmc2MtPnNjX210eCk7CiAgICAgICAgICAgIHJl dHVybiBlcnJvcjsKICAgICAgICB9CiAgICAgICAgd3JvdGUgKz0gdG9jb3B5OwogICAgfQoKICAg IC8qIElmIHVzZXIgcHJvdmlkZWQgbGVzcyB0aGFuIGV4cGVjdGVkLCB3ZSBzdGlsbCBzZW5kIHdo YXQgd2UgaGF2ZS4gKi8KICAgIGVycm9yID0gd3MyODEyX3NlbmQoc2MsIHNjLT5idWYsIHdyb3Rl KTsKCiAgICBtdHhfdW5sb2NrKCZzYy0+c2NfbXR4KTsKICAgIHJldHVybiBlcnJvcjsKfQoKc3Rh dGljIGludAp3c19pb2N0bChzdHJ1Y3QgY2RldiAqZGV2LCB1X2xvbmcgY21kLCBjYWRkcl90IGRh dGEsIGludCBmZmxhZywgc3RydWN0IHRocmVhZCAqdGQpCnsKICAgIHN0cnVjdCB3c19zb2Z0YyAq c2MgPSBnbG9iYWxfc2M7CiAgICBpbnQgdmFsOwoKICAgIGlmIChzYyA9PSBOVUxMKQogICAgICAg IHJldHVybiBFTlhJTzsKCiAgICBzd2l0Y2ggKGNtZCkgewogICAgY2FzZSBXU19JT0NUTF9TRVRf TEVEX0NPVU5UOgogICAgICAgIHZhbCA9ICooaW50ICopZGF0YTsKICAgICAgICBpZiAodmFsIDw9 IDAgfHwgdmFsID4gMTAwMDApCiAgICAgICAgICAgIHJldHVybiBFSU5WQUw7CiAgICAgICAgbXR4 X2xvY2soJnNjLT5zY19tdHgpOwogICAgICAgIHNjLT5sZWRfY291bnQgPSB2YWw7CiAgICAgICAg aWYgKHNjLT5idWYpIHsKICAgICAgICAgICAgZnJlZShzYy0+YnVmLCBNX0RFVkJVRik7CiAgICAg ICAgICAgIHNjLT5idWYgPSBOVUxMOwogICAgICAgIH0KICAgICAgICBtdHhfdW5sb2NrKCZzYy0+ c2NfbXR4KTsKICAgICAgICBicmVhazsKICAgIGNhc2UgV1NfSU9DVExfU0VUX0JBQ0tFTkQ6CiAg ICAgICAgdmFsID0gKihpbnQgKilkYXRhOwogICAgICAgIGlmICh2YWwgIT0gV1NfQkFDS0VORF9H UElPICYmIHZhbCAhPSBXU19CQUNLRU5EX1NQSSkKICAgICAgICAgICAgcmV0dXJuIEVJTlZBTDsK ICAgICAgICBtdHhfbG9jaygmc2MtPnNjX210eCk7CiAgICAgICAgc2MtPmJhY2tlbmQgPSB2YWw7 CiAgICAgICAgbXR4X3VubG9jaygmc2MtPnNjX210eCk7CiAgICAgICAgYnJlYWs7CiAgICBjYXNl IFdTX0lPQ1RMX1NFVF9HUElPX1BJTjoKICAgICAgICB2YWwgPSAqKGludCAqKWRhdGE7CiAgICAg ICAgbXR4X2xvY2soJnNjLT5zY19tdHgpOwogICAgICAgIHNjLT5ncGlvX3BpbiA9IHZhbDsKICAg ICAgICBtdHhfdW5sb2NrKCZzYy0+c2NfbXR4KTsKICAgICAgICBicmVhazsKICAgIGNhc2UgV1Nf SU9DVExfU0VUX0dSQjoKICAgICAgICB2YWwgPSAqKGludCAqKWRhdGE7CiAgICAgICAgbXR4X2xv Y2soJnNjLT5zY19tdHgpOwogICAgICAgIHNjLT5ncmIgPSB2YWwgPyAxIDogMDsKICAgICAgICBt dHhfdW5sb2NrKCZzYy0+c2NfbXR4KTsKICAgICAgICBicmVhazsKICAgIGRlZmF1bHQ6CiAgICAg ICAgcmV0dXJuIEVOT1RUWTsKICAgIH0KCiAgICByZXR1cm4gMDsKfQoKLyogTW9kdWxlIGxvYWQv dW5sb2FkICovCnN0YXRpYyBpbnQKd3NfbG9hZGVyKHN0cnVjdCBtb2R1bGUgKm0sIGludCB3aGF0 LCB2b2lkICphcmcpCnsKICAgIGludCBlcnIgPSAwOwogICAgc3dpdGNoICh3aGF0KS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ogICAgICAgIH0KICAgICAgICBpZiAod3NfZGV2KQogICAg ICAgICAgICBkZXN0cm95X2Rldih3c19kZXYpOwogICAgICAgIHByaW50Zigid3MyODEyOiBtb2R1 bGUgdW5sb2FkZWQuXG4iKTsKICAgICAgICBicmVhazsKICAgIGRlZmF1bHQ6CiAgICAgICAgZXJy ID0gRU9QTk9UU1VQUDsKICAgICAgICBicmVhazsKICAgIH0KICAgIHJldHVybiBlcnI7Cn0KCkRF Vl9NT0RVTEUod3MyODEyLCB3c19sb2FkZXIsIE5VTEwpOwpNT0RVTEVfVkVSU0lPTih3czI4MTIs IDEpOwpNT0RVTEVfREVQRU5EKHdzMjgxMiwgZ3BpbywgMCwgMCwgMCk7IC8qIG9wdGlvbmFsOyBk cml2ZXIgZG9lc24ndCBjdXJyZW50bHkgdXNlIGdwaW9idXMgKi8KCi8qCiAqIFJFQURNRSAoaW4t Y29kZSkg4oCUIGJ1aWxkICYgdXNlOgogKgogKiAxKSBDb3B5IHRoaXMgZmlsZSB0byAvdXNyL3Ny Yy9zeXMvbW9kdWxlcy93czI4MTIvd3MyODEyLmMgKG9yIGtlZXAgaW4gYQogKiAgICBsb2NhbCBk aXJlY3RvcnkpLgogKgogKiAyKSBDcmVhdGUgYSBNYWtlZmlsZSBpbiB0aGUgc2FtZSBkaXJlY3Rv cnk6CiAqCiAqICAgIEtNT0QgICAgPSB3czI4MTIKICogICAgU1JDUyAgICA9IHdzMjgxMi5jCiAq ICAgIC5pbmNsdWRlIDxic2Qua21vZC5taz4KICoKICogMykgQnVpbGQgYW5kIGluc3RhbGw6CiAq ICAgICMgY2QgL3Vzci9zcmMvc3lzL21vZHVsZXMvd3MyODEyCiAqICAgICMgbWFrZQogKiAgICAj IG1ha2UgaW5zdGFsbAogKgogKiA0KSBMb2FkIHRoZSBtb2R1bGU6CiAqICAgICMga2xkbG9hZCB3 czI4MTIKICoKICogNSkgQ29uZmlndXJlIGRldmljZToKICogICAgIyBlY2hvIDYwID4gL2Rldi93 czI4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k ZGl0aW9uYWwKICogICAgcHJpdmlsZWdlczsgcmVzdWx0cyBtYXkgdmFyeS4KICogIC0gSWYgeW91 IHdhbnQgaGVscCBhZGFwdGluZyB0aGlzIHRvIGEgc3BlY2lmaWMgYm9hcmQgKFJhc3BiZXJyeSBQ aSwKICogICAgQmVhZ2xlQm9uZSwgZXRjLiksIHRlbGwgbWUgdGhlIGV4YWN0IGJvYXJkIGFuZCBr ZXJuZWwgdmVyc2lvbiBhbmQgSSBjYW4KICogICAgZXh0ZW5kIHRoZSBkcml2ZXIgdG8gdXNlIFNQ SS9QV00gd2l0aCB3b3JraW5nIGNvZGUuCiAqLwo= ------YDXK3PT53ST1YG9Y6H0JR7R44WPHEB Content-Type: text/x-csrc; name=ws2812_userland.c Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=ws2812_userland.c; size=3351 LyoKICogd3MyODEyX3VzZXJsYW5kLmMKICogRXhhbXBsZSB1c2VybGFuZCBwcm9ncmFtIHRvIGRy aXZlIHRoZSB3czI4MTIgRnJlZUJTRCBrZXJuZWwgbW9kdWxlLgogKgogKiBGZWF0dXJlczoKICog IC0gT3BlbnMgL2Rldi93czI4MTIKICogIC0gQ29uZmlndXJlcyBMRUQgY291bnQsIGJhY2tlbmQs IEdQSU8gcGluLCBhbmQgR1JCIG9yZGVyaW5nIHZpYSBpb2N0bAogKiAgLSBTZW5kcyBhIHNpbXBs ZSBjb2xvciBwYXR0ZXJuIChyYWluYm93IHN3ZWVwKQogKgogKiBCdWlsZDoKICogICBjYyAtV2Fs bCAtTzIgLW8gd3MyODEyX3VzZXJsYW5kIHdzMjgxMl91c2VybGFuZC5jCiAqCiAqIFJ1bjoKICog ICAuL3dzMjgxMl91c2VybGFuZCAvZGV2L3dzMjgxMgogKi8KCiNpbmNsdWRlIDxzdGRpby5oPgoj aW5jbHVkZSA8c3RkbGliLmg+CiNpbmNsdWRlIDxzdGRpbnQuaD4KI2luY2x1ZGUgPGZjbnRsLmg+ CiNpbmNsdWRlID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GNhc2UgMjogKnIgPSBwKjI1 NTsgKmcgPSB2KjI1NTsgKmIgPSB0KjI1NTsgYnJlYWs7CiAgICAgICAgY2FzZSAzOiAqciA9IHAq MjU1OyAqZyA9IHEqMjU1OyAqYiA9IHYqMjU1OyBicmVhazsKICAgICAgICBjYXNlIDQ6ICpyID0g dCoyNTU7ICpnID0gcCoyNTU7ICpiID0gdioyNTU7IGJyZWFrOwogICAgICAgIGNhc2UgNTogKnIg PSB2KjI1NTsgKmcgPSBwKjI1NTsgKmIgPSBxKjI1NTsgYnJlYWs7CiAgICB9Cn0KCmludCBtYWlu KGludCBhcmdjLCBjaGFyICoqYXJndikKewogICAgaW50IGZkOwogICAgaW50IGxlZF9jb3VudCA9 IDYwOwogICAgaW50IGJhY2tlbmQgPSBXU19CQUNLRU5EX0dQSU87CiAgICBpbnQgZ3Bpb19waW4g PSAwOyAgIC8qIGFkanVzdCBmb3IgeW91ciBib2FyZCAqLwogICAgaW50IGdyYiA9IDE7ICAgICAg ICAvKiBXUzI4MTIgdXNlcyBHUkIgKi8KCiAgICBpZiAoYXJnYyA8IDIpIHsKICAgICAgICBmcHJp bnRmKHN0ZGVyciwgIlVzYWdlOiAlcyAvZGV2L3dzMjgxMiBbbGVkc11cbiIsIGFyZ3ZbMF0pOwog ICAgICAgIHJldHVybiAxOwogICAgfQoKICAgIGlmIChhcmdjID49IDMpCiAgICAgICAgbGVkX2Nv dW50ID0gYXRvaShhcmd2WzJdKTsKCiAgICBzaXplX3QgYnVmX3NpemUgPSBsZWRfY291bnQgKiAz OwogICAgdWludDhfdCAqYnVmID0gbWFsbG9jKGJ1Zl9zaXplKTsKICAgIGlmICghYnVmKSB7CiAg ICAgICAgcGVycm9yKCJtYWxsb2MiKTsKICAgICAgICByZXR1cm4gMTsKICAgIH0KCiAgICBmZCA9 IG9wZW4oYXJndlsxXSwgT19XUk9OTFkpOwogICAgaWYgKGZkIDwgMCkgewogICAgICAgIHBlcnJv cigib3BlbiIpOwogICAgICAgIHJldHVybiAxOwogICAgfQoKICAgIC8qIGNvbmZpZ3VyZSBkcml2 ZXIgKi8KICAgIGlmIChpb2N0bChmZCwgV1NfSU9DVExfU0VUX0xFRF9DT1VOVCwgJmxlZF9jb3Vu dCkgPCAwKQogICAgICAgIHBlcnJvcigiaW9jdGwgTEVEX0NPVU5UIik7CiAgICBpZiAoaW9jdGwo ZmQsIFdTX0lPQ1RMX1NFVF9CQUNLRU5ELCAmYmFja2VuZCkgPCAwKQogICAgICAgIHBlcnJvcigi aW9jdGwgQkFDS0VORCIpOwogICAgaWYgKGlvY3RsKGZkLCBXU19JT0NUTF9TRVRfR1BJT19QSU4s ICZncGlvX3BpbikgPCAwKQogICAgICAgIHBlcnJvcigiaW9jdGwgR1BJT19QSU4iKTsKICAgIGlm IChpb2N0bChmZCwgV1NfSU9DVExfU0VUX0dSQiwgJmdyYikgPCAwKQogICAgICAgIHBlcnJvcigi aW9jdGwgR1JCIik7CgogICAgcHJpbnRmKCJEcml2aW5nICVkIExFRHMuLi4gcHJlc3MgQ3RybCtD IHRvIHN0b3AuXG4iLCBsZWRfY291bnQpOwoKICAgIGZsb2F0IGggPSAwLjBmOwogICAgd2hpbGUg KDEpIHsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGxlZF9jb3VudDsgaSsrKSB7CiAgICAg ICAgICAgIGZsb2F0IGxlZF9oID0gaCArIChmbG9hdClpIC8gbGVkX2NvdW50OwogICAgICAgICAg ICB1aW50OF90IHIsIGcsIGI7CiAgICAgICAgICAgIGhzdl90b19yZ2IobGVkX2gsIDEuMGYsIDAu NWYsICZyLCAmZywgJmIpOwoKICAgICAgICAgICAgaWYgKGdyYikgewogICAgICAgICAgICAgICAg YnVmW2kqMyArIDBdID0gZzsKICAgICAgICAgICAgICAgIGJ1ZltpKjMgKyAxXSA9IHI7CiAgICAg ICAgICAgICAgICBidWZbaSozICsgMl0gPSBiOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAg ICAgICAgICAgYnVmW2kqMyArIDBdID0gcjsKICAgICAgICAgICAgICAgIGJ1ZltpKjMgKyAxXSA9 IGc7CiAgICAgICAgICAgICAgICBidWZbaSozICsgMl0gPSBiOwogICAgICAgICAgICB9CiAgICAg ICAgfQoKICAgICAgICBzc2l6ZV90IHcgPSB3cml0ZShmZCwgYnVmLCBidWZfc2l6ZSk7CiAgICAg ICAgaWYgKHcgPCAwKSB7CiAgICAgICAgICAgIHBlcnJvcigid3JpdGUiKTsKICAgICAgICAgICAg YnJlYWs7CiAgICAgICAgfQoKICAgICAgICBoICs9IDAuMDA1ZjsKICAgICAgICBpZiAoaCA+IDEu MGYpIGggLT0gMS4wZjsKICAgICAgICB1c2xlZXAoMjAwMDApOyAvKiAyMG1zICovCiAgICB9Cgog ICAgY2xvc2UoZmQpOwogICAgZnJlZShidWYpOwogICAgcmV0dXJuIDA7Cn0K ------YDXK3PT53ST1YG9Y6H0JR7R44WPHEB--