Cov txheej txheem:

LED POVstick Nrog Bluetooth Tsawg Zog: 10 Kauj Ruam (nrog Duab)
LED POVstick Nrog Bluetooth Tsawg Zog: 10 Kauj Ruam (nrog Duab)

Video: LED POVstick Nrog Bluetooth Tsawg Zog: 10 Kauj Ruam (nrog Duab)

Video: LED POVstick Nrog Bluetooth Tsawg Zog: 10 Kauj Ruam (nrog Duab)
Video: Tik Tok || Tseem Nco Koj Thiab Kuv P15 2024, Hlis ntuj nqeg
Anonim
LED POVstick Nrog Bluetooth Tsawg Zog
LED POVstick Nrog Bluetooth Tsawg Zog

Cov lus qhia no qhia koj yuav ua li cas tsim lub teeb sau ntawv nrog RGB LEDs uas tuaj yeem tswj tau ntawm BLE los ntawm koj lub xov tooj!

Tam sim no lub caij tsaus ntuj pib thiab koj yuav tsum tau thaij duab ntev: Nrog tus pas no koj tuaj yeem sau koj lub npe rau hauv daim duab, lossis cov lus txhawb siab, lossis tshaj tawm kev hlub, QR-code, web-adresse, lossis ntau lwm yam…

Nws npog ntau lub ncauj lus ntawm kev txhim kho:

  • tsim kho vajtse
  • programming Cypress BLE chipset nrog C.
  • ua koj tus kheej app los tswj nws.

Kauj Ruam 1: Kho vajtse rau BLE-LED-Stick

Kho vajtse rau BLE-LED-Stick
Kho vajtse rau BLE-LED-Stick
Kho vajtse rau BLE-LED-Stick
Kho vajtse rau BLE-LED-Stick
Kho vajtse rau BLE-LED-Stick
Kho vajtse rau BLE-LED-Stick
Kho vajtse rau BLE-LED-Stick
Kho vajtse rau BLE-LED-Stick

Rau lub stick koj xav tau cov hauv qab no:

  • Cypress BLE tus qauv (CY8C4247LQI-BL583)
  • WS2812b RGB-LED-Sawb (64LEDs los ntawm 144Led ib lub 'meter' sawb)
  • lub roj teeb Li-Ion nrog tus tuav haum (18650)
  • lub laub
  • ib daim ntawm daim ntawv qhia zaub mov

Kho vajtse ntawm tus pas nws tus kheej yog qhov yooj yim heev.

Cypress BLE tus qauv tau teeb tsa ntawm ib daim ntawv ntawm lub khob cij thiab cov LEDs, lub pob thiab lub zog-tsuas yog txuas nrog lub khob cij no.

Txhua yam tau teeb tsa, glued lossis ntsia mus rau ib qho me me ntawm cov ntoo ntoo, uas nws tus kheej yog ib nrab tso rau hauv lub raj polyacryl meej. Tab sis qhov no tsis tas yuav tsum tau ua. Kuv xav nce txhua yam hauv lub raj, tab sis kuv tsis pom qhov tsim nyog rau BLE-module thiab lub roj teeb uas loj heev, piv rau LEDs. Rau qhov txhaj tshuaj thawj zaug koj tsis xav tau lub raj-acryl.

Kauj Ruam 2: Cov Khoom Siv Hluav Taws Xob

Kev Sib Txuas Hluav Taws Xob
Kev Sib Txuas Hluav Taws Xob
Electronics los ua ke
Electronics los ua ke

Cov theem no qhia koj li cas BLE-module tau teeb tsa thiab cov pins twg tau siv rau lub hom phiaj twg.

Raws li hauv ob peb ntawm Kuv Cov Lus Qhia Kuv siv Cypress BLE Cov Khoom Siv Txhim Kho. CY8CKIT-042-BLE Kev Pib Ceev Qhia

Yog tias koj xav ua haujlwm tus qauv ntawm nws tus kheej, txhua yam koj xav tau txuas yog lub zog siv thiab cov pins siv.

Rau peb txoj haujlwm peb tsuas yog siv tus pin 3.5 txhawm rau tsav LED-Sawb. Tab sis tau kawg koj tuaj yeem hloov qhov ntawd nrog PSoC Tus Tsim.

Raws li koj tuaj yeem pom hauv daim duab ntawm PCB, Kuv ntxiv tus pinheads hauv txhua lub ces kaum ntawm lub nti tab sis kuv hla tus VREF tus pin.

Txoj hauv kev no tus qauv tau teeb tsa kom raug thiab nws tsis tuaj yeem txuas qhov tsis raug.

Kauj Ruam 3: Yuav Ua Li Cas Tsim Cov Fonts?

Yuav Ua Li Cas Tsim Cov Fonts?
Yuav Ua Li Cas Tsim Cov Fonts?

Zoo, kuv xav tias qhov no yog ib qho ntawm cov teeb meem nthuav tshaj plaws kuv tau daws thaum lub sijhawm ua haujlwm no.

Tau kawg ib tus tuaj yeem tsim tus font tshiab thiab sau nws hauv kab ntawv, tab sis qhov ntawd yog haujlwm tiag tiag!

Yog li kuv tau ua dab tsi?

Kuv paub tias kuv xav tau qee yam ntawm ASCII rau hex-bitmap hloov dua siab tshiab. Thiab kuv muaj hmoo, vim tias kuv tsis yog thawj tus nrog qhov teeb meem no!:-)

Lub software "GLCD Font Generator" tsuas yog ua qhov raug:

Vim tias kuv xav kom tau txais txiaj ntsig tshaj plaws ntawm LED-stick, Kuv tau xa cov font hauv qhov loj dua (~ 32pixel). Yog tias koj tsuas yog siv cov tsiaj ntawv loj koj tsis tas yuav mob siab rau kev nce qib, uas yuav ua rau koj pom qhov font-loj dua ob peb lub pixels. Tab sis kuv tau xaiv siv ob lub nroog loj thiab cov tsiaj ntawv me me. (https://en.wikipedia.org/wiki/Ascender_%28typography%29)

Thaum koj import tus font rau hauv GLCD Font generator koj tuaj yeem xaiv xa nws tawm hauv ntau hom ntawv.

Kuv sim xa nws ncaj qha mus rau hauv cov ntawv uas yog qhov zoo, tab sis tsis zoo tag nrho. Qhov txiaj ntsig xa tawm yog ib qho luv luv (16 ntsis) nrog byte-hex-qhov tseem ceeb rau kab rau txhua tus cim ntawm thawj 128-ascii tus cim. Tsis yog yam kuv xav tau lossis xav tau …

Yog li kuv tau xa cov kab ntawv mus rau hauv daim ntawv qhib chaw ua haujlwm calc. Tom qab ntawd kuv tshem tawm "0x" ntawm peb ntawm plaub qhov txiaj ntsig thiab sib txuas lawv rau hauv ib qho 32 ntsis ntev tus nqi. Kuv kuj kho qhov tsis raug qhov tseeb ntawm tus kheej bytes.

Cov txiaj ntsig tau tshwm sim yog N*M array ntawm 32 ntsis qhov tseem ceeb. M yog tus yam ntxwv tshwj xeeb thiab N yog kab ntawv uas ua rau pom cov ntawv no. Hauv thawj daim phiaj xwm no txhua tus cim muaj tus lej sib thooj, uas txhais tau tias txhua tus ntawv yog dav sib npaug, zoo li hauv tus paub Courier font. Cov cim me me zoo li "i" lossis "t" zoo li lawv poob hauv qhov chaw.

Yog li kuv tau ntxiv qhov ntsuas tshiab thaum pib ntawm txhua tus cim los qhia, ntau npaum li cas txhua tus cim no muaj lossis ntau npaum li cas tus yam ntxwv no. Qhov no txuag lub cim xeeb thiab ua kom cov ntawv zoo dua!

Kauj Ruam 4: BLE Tswj Software

BLE Tswj Software
BLE Tswj Software

Lub hauv paus ntsiab lus ntawm BLE-software yog qhov yooj yim heev:

  • Thaum pib nws tsuas yog tsis ua dab tsi.
  • Ntawm BLE koj tuaj yeem teeb tsa cov duab sib txawv lossis cov ntawv kom pom.
  • Thaum koj nias lub pob, txhua kab ntawm cov tsiaj ntawv lossis cov ntawv raug nthuav tawm.
  • Tom qab cov ntawv tau tshwm, nws tseem tos ntxiv.

Tsuas yog ntshuam cov phiaj xwm cypress rau koj li PSoC-Creator thiab hloov kho yog tias koj nyiam.

PSoC-4 tsis muaj RAM ntau thiab nyem kom muaj peev xwm tuav tau RGB-cov duab ntawm cov ntawv. Yog li kuv xav tau txoj hauv kev los tsim cov LED-cov ntsiab lus zoo los ntawm cov ntawv. Qhov ntawd yog qhov ncaj ncaj, tsis muaj dab tsi tshwj xeeb txog tam sim no. Los ntawm cov ntawv nrog ntau tus tsiaj ntawv, cov txheej txheem siv ib tsab ntawv thiab hloov nws mus rau hauv cov xim dub-dawb-bitmap. Tom qab ntawd nws yuav siv txhua kab lus ntawm no ib tsab ntawv-me ntsis thiab hloov dawb, nws sau tam sim no RGB-xim rau LED-array. Txoj hauv kev no koj tuaj yeem tsim cov ntawv ib leeg-xim lossis los ntawm kev ua haujlwm ntxiv hloov xim tom qab txhua kab ntawv, txhua tsab ntawv lossis txawm tias tom qab txhua lub pixel.

Ib "ntawv" tuaj yeem khaws cia hauv ib qho byte-variable thaum dub thiab dawb bitmap xav tau khaws cia hauv qee yam ntawm cov khoom.

Cov ntaub ntawv-qauv yog qhov no:

Txoj hlua: newtext = "Nyob zoo";

Font: uint32 cim = {FirstCharacter_ColumnCount, FirstCharacter_FirstColumn, FirstCharacter_SecondColumn,… SecondCharacter_ColumnCount, SecondCharacter_FirstColumn,…… LastCharacter_ColumnCount,… LastCharacter_LastColumn}; Xim: uint32 rgbcolor = 0xHHBBGGRR; // Lub teeb ci, Xiav, Ntsuab, Liab txhua li 8 ntsis tus nqi

Txhawm rau hloov txoj hlua rau zaub peb ua cov hauv qab no:

getCharacter (): H (8 ntsis)

getColumn (int i): kem (32 ntsis) (kuv pib nrog thawj kab, sau mus txog qhov kawg.) yog (me ntsis hauv kab ntawv yog 1) LED hauv Sawb tau teeb xim LED-Sawb Array yog 64 LEDs nrog 32 ntsis xim ib leeg!

Thiab yog tias kab ntawv no tau tshwm sim peb txuas ntxiv nrog tom ntej no.

Nws yog qhov yooj yim no.

Kauj Ruam 5: Thawj Xeem

Kev Xeem Thawj
Kev Xeem Thawj
Kev Xeem Thawj
Kev Xeem Thawj
Kev Xeem Thawj
Kev Xeem Thawj

Tam sim no qhov software ua haujlwm, peb tau npaj rau thawj qhov kev sim.

Txoj hauv kev yooj yim tshaj plaws los sim ua lub luag haujlwm yog nrog Bluetooth qis lub zog ntsuas app. Zoo li Nordic lossis Cypress Apps.

Nordic: nRF Txuas rau Txawb

Cypress: CySmart

Pib Pov-Stick thiab saib yuav ua li cas qhov demo-hlua yuav tshwm. Thaum qhov no ua tiav nws yog lub sijhawm los pib lub app. Tshawb nrhiav Povstick ntaus ntawv thiab nyem rau txuas.

Thaum qhov kev sib txuas raug teeb tsa lub app cia li tshawb pom txhua qhov kev pabcuam thiab tus yam ntxwv.

Nrhiav thawj qhov kev pabcuam (yuav tsum pib nrog 0000ccce…). Nyem rau nws qhib nws thiab tso tawm thawj tus yam ntxwv (pib nrog 0000ccc1). Tom qab ntawd nyem qhov sau (lossis rub tawm) khawm thiab sau 01 rau tus yam ntxwv no.

Thaum koj tsoo xa mus, POVstick yuav pib Xim-Knight-rider animation aka Larson Scanner nrog hloov xim.

Zoo siab koj tau xa koj thawj tus nqi ntawm BLE!

Kauj ruam 6: Xaiv cov Animations

Xaiv cov Animations
Xaiv cov Animations
Xaiv cov Animations
Xaiv cov Animations
Xaiv cov Animations
Xaiv cov Animations
Xaiv cov Animations
Xaiv cov Animations

Hauv software peb tau piav qhia qhov enum "e_Animation" nrog cov txiaj ntsig hauv qab no:

typedef enum {Knightrider = 0, ColorKnightRider, Rainbowswirl, Valueswirl, WS_CandyCane, WS_CandyCane_2, WS_CandyCane_3, WS_Twinkle, WS_Icicle, WS_ColorWheel, RGB_Control, TextAnimation, Animation_Max} eA

Cov no yog cov txiaj ntsig uas siv tau rau ccc1 tus yam ntxwv. Yog tias koj xav pom CandyCane-Animation koj yuav tsum sau 4, 5 lossis 6 rau tus yam ntxwv no. Lawv txawv ntawm cov xim.

Ob qhov tshwj xeeb ua yeeb yaj kiab yog RGB_Control thiab TextAnimation. Yog tias koj xaiv qhib cov no, tus pas yuav pom tseeb tsis muaj dab tsi thaum xub thawj. Tab sis nws muab koj cov kev xaiv ntxiv los tswj tus pas nrog lwm cov kev pabcuam.

Kauj Ruam 7: RGB Tswj

RGB Tswj
RGB Tswj
RGB Tswj
RGB Tswj
RGB Tswj
RGB Tswj
RGB Tswj
RGB Tswj

RGB-Tswj tau yooj yim sim nrog CySmart App vim tias kuv siv tib UUID rau tus yam ntxwv zoo li hauv Cypress Demo.

Pib CySmart app thiab txuas rau Povstick. Ua ntej koj yuav tsum sau "0x0A" rau ccc1 tus yam ntxwv.

0x0A yog tus lej hex rau 10, uas yog RGB-Tswj kev ua yeeb yaj kiab hauv qhov enum.

Tom qab ntawd koj tuaj yeem hloov mus rau RGB-LED Tswj Vaj Huam Sib Luag hauv CySmart App. Tej zaum koj yuav tsum rov pib dua lub app kom tau mus rau lub vijtsam no. Tom qab ntawd koj tuaj yeem tswj cov xim ntawm txhua lub LEDs nrog daim duab RGB no.

Tau kawg koj tseem tuaj yeem sau qhov tseem ceeb ncaj qha rau tus yam ntxwv.

Kauj Ruam 8: Kev Pabcuam Text_Animation thiab Kev Pabcuam Txuas Ntxiv

Text_Animation Service thiab Muab Kev Pab Cuam
Text_Animation Service thiab Muab Kev Pab Cuam

Cov kev pabcuam no tsis yooj yim rau kev sim.

Cov txheej txheem koj tseem tuaj yeem siv nordic app rau qhov no, tab sis koj yuav tsum paub qhov muaj nuj nqis dab tsi los sau rau tus yam ntxwv twg.

Yog li yog tias koj xav sim cov no, koj yuav tsum tau saib ntawm PSoC txoj haujlwm, yam ntxwv twg muaj UUID.

Ib qho tseem ceeb ntawm tus yam ntxwv "Teeb-Ceev". Nrog tus yam ntxwv no koj tuaj yeem tswj tau qhov nrawm nrawm.

Nrog rau "Set_Animation" tus yam ntxwv ntawm PersistentStorageService koj tuaj yeem tswj fonts thiab xim ntawm kab ntawv. Cov txiaj ntsig siv tau raug piav qhia hauv "povanimation.h", ob daim ntawv "mono" thiab "serif" thiab ib qho xim thiab zaj sawv xim. Qhov tseem ceeb 0 thiab 1 tso tawm cov ntawv nrog xim ruaj khov, tswj tau ntawm RGB_Control tus yam ntxwv. Qhov tseem ceeb 2 thiab 3 hloov xim rau txhua kab ntawv thiab muab txoj hlua rau zaj sawv zoo.

Qhov "Write_Text_Service" zoo ib yam. Koj tuaj yeem sau txoj hlua tshiab rau lub cuab yeej los ntawm kev sau tus cim rau tus "Set_Character" tus yam ntxwv. Ntawm txhua qhov sau, koj yuav tau txais kev ceeb toom rov qab ntawm qhov ntev ntawm txoj hlua.

Txhawm rau pib txoj hlua tshiab, sau "tseeb" rau "Clear_String".

Qhov no tsis yog qhov ua tau zoo tshaj plaws, tab sis nws ua haujlwm rau ib txoj hlua txog 250 tus cim yam tsis hloov pauv qhov loj ntawm MTU.

Cov zaub ntawm txoj hlua tshiab nrog pib thaum lub pob ntawm Povstick raug nias.

Kauj ruam 9: Pib Android App

Qhov no yog ib kauj ruam tseem ceeb, tab sis txoj kev dhau ntawm qhov kev qhia no. Thov txim rau qhov ntawd!

Tej zaum kuv yuav xa kuv cov ntawv xeem-app mus rau tom khw, tab sis nws tseem tsis tau tiav lossis tso tawm.

Kauj Ruam 10: Sau Cov Lus hauv Cov Duab

Sau Cov Lus hauv Duab
Sau Cov Lus hauv Duab
Sau Cov Lus hauv Duab
Sau Cov Lus hauv Duab
Sau Cov Lus hauv Duab
Sau Cov Lus hauv Duab

Zoo, qhov no yog vim li cas kuv thiaj tsim cov povstick no ua ntej: Sau cov lus hauv duab.

Koj xav tau lub koob yees duab, lub koob yees duab nrog qhov ua haujlwm ntev thiab qee qhov chaw zoo.

Teeb lub koob yees duab thiab kho lub sijhawm raug rau 10s rau thawj qhov kev sim.

Ua rau tso tawm thiab pib taug kev los ntawm daim duab, pib cov ntawv-tso tawm ntawm tus pas.

Et Voila peb nyob ntawm no!

Nrog txoj kev sib xyaw ua ke ntawm LED-ci ci, lub qhov taub thiab lub sijhawm raug nws tseem tuaj yeem thaij duab thaum kaj ntug.

Peb daim duab hauv qib no qhia txog qhov ua tau zoo ntawm qhov ua tau.

Hauv thawj, cov LEDs tau tshaj tawm thiab tsim lub ntsej muag ci ntsa iab. Tab sis yog vim li cas qhov kev xav ntawm hauv av pom thiab keeb kwm yav dhau zoo dua.

Daim duab thib ob tau nthuav tawm rau LEDs, tab sis qhov ntawd ua rau tom qab dub tag.

Thiab qhov thib peb qhia pom qhov tsaus nti LEDs sai tom qab hnub poob. Cov LEDs zoo ib yam li hauv lwm daim duab, tab sis ib puag ncig tau ci ntsa iab uas kuv yuav tsum tau siv lub ntsej muag qis thiab ISO qis kom cov LEDs zoo li tsaus ntuj.

Ua nws Glow Contest 2018
Ua nws Glow Contest 2018
Ua nws Glow Contest 2018
Ua nws Glow Contest 2018

Qhov khoom plig thib ob hauv Kev Ua Nws Glow Contest 2018

Pom zoo: