IgorXDDD
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: 'ZAP sprawozdanie z projektu' # subtitle: 'dokumentacja końcowa' to: latex+footnotes standalone: true output: zap_dokumentacja.pdf lang: pl-PL date: \today{} author: - "Igor Kaźmierczak 293118" - "Tymoteusz Perka" geometry: - bottom=2cm - top=2cm - left=1cm - right=1cm footnotes: true toc: true ... # ZAP projekt sprawozdanie ## Treść zadania: Sterowanie jasnością oświetlenia ze smartfona przez BLE przy użyciu modułu z mikrokontrolerem nRF51822. ## Środowisko W celu wytworzenia oprogramowania na płytkę nRF52840 użyta została wtyczka `nRD Connect for VS CODE` wraz ze współpracujacymi z nią innymi rozszerzeniami znajdującymi się w pakiecie `nRF Connect Extension Pack` - rozszerzeniu do edytora `Visual Studio Code`. Proces instalacji rozszerzenia oraz pisania programów był wspomagany [serią poradników w serwisie YouTube.](https://www.youtube.com/watch?v=2cv_jjqk5hg&list=PLx_tBuQ_KSqEt7NK-H7Lu78lT2OijwIMl) Aplikacja na telefon, która została wykorzystana przy testowaniu, to `nRF Connect`, dostępna do pobrania w sklepie `Google Play`. ## Modyfikacja plików konfiguracyjnych płytki nRF52840dk Podczas próby obsłużenia wszystkich (czterech) modułów PWM znajdujących się na płytce, został napotkany problem z jej konfiguracją: pliki konfiguracyjne przewidywały występowanie tylko jednej diody PWM, podczas gdy w rzeczywistości było ich cztery. W celu eliminacji wspomnianego problemu zmodyfikowane zostały następujące pliki: ### `nrf52840dk_nrf52840.dts` znajduje się w folderze `{INSTALATION_DIR}\v1.8.0\zephyr\boards\arm\nrf52840dk_nrf52840\` - ```c= pwmleds { compatible = "pwm-leds"; pwm_led0: pwm_led_0 { pwms = <&pwm0 13>; }; }; ``` zostało zamienione na: ```c= pwmleds { compatible = "pwm-leds"; pwm_led0: pwm_led_0 { pwms = <&pwm0 13>; }; pwm_led1: pwm_led_1 { pwms = <&pwm1 14>; }; pwm_led2: pwm_led_2 { pwms = <&pwm2 15>; }; pwm_led3: pwm_led_3 { pwms = <&pwm3 16>; }; }; ``` - ```c= aliases { led0 = &led0; led1 = &led1; led2 = &led2; led3 = &led3; pwm-led0 = &pwm_led0; sw0 = &button0; sw1 = &button1; sw2 = &button2; sw3 = &button3; bootloader-led0 = &led0; }; ``` zostało zamienione na: ```c= aliases { led0 = &led0; led1 = &led1; led2 = &led2; led3 = &led3; pwm-led0 = &pwm_led0; pwm-led1 = &pwm_led1; pwm-led2 = &pwm_led2; pwm-led3 = &pwm_led3; sw0 = &button0; sw1 = &button1; sw2 = &button2; sw3 = &button3; bootloader-led0 = &led0; }; ``` - ```c= &pwm0 { status = "okay"; ch0-pin = <13>; ch0-inverted; }; ``` zostało zamienione na: ```c= &pwm0 { status = "okay"; ch0-pin = <13>; ch0-inverted; }; &pwm1 { status = "okay"; ch0-pin = <14>; ch0-inverted; }; &pwm2 { status = "okay"; ch0-pin = <15>; ch0-inverted; }; &pwm3 { status = "okay"; ch0-pin = <16>; ch0-inverted; }; ``` ### `nordic,nrf-sw-pwm.yaml` znajduje się w folderze `{INSTALATION_DIR}\v1.8.0\zephyr\dts\bindings\pwm\` - ```c= "#pwm-cells": const: 1 ``` zostało zamienione na: ```c= "#pwm-cells": const: 4 ``` Powyższe modyfikacje pozwoliły wykrywać jak i korzystać ze wszystkich czterech modułów PWM znajdujących się na płytce. ## Przygotowanie programu W celu przygotowania plików źródłowych oraz nagłówkowych niezbędne jest wygenerowanie tzw. *buildu*, informacje o którym zawarte są w pliku `prj.conf`. W przedstawianym projekcie wspomniany plik miał następującą zawartość: ``` CONFIG_NCS_SAMPLES_DEFAULTS=y CONFIG_BT=y CONFIG_BT_PERIPHERAL=y CONFIG_BT_DEVICE_NAME="PROJEKT_ZAP" CONFIG_BT_LBS=y CONFIG_BT_LBS_POLL_BUTTON=y CONFIG_DK_LIBRARY=y CONFIG_LOG=y CONFIG_PWM=y CONFIG_LED=y CONFIG_LED_PWM=y CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 ``` Generowanie *buildu* opartego na powyższym pliku konfiguracyjnym wystawiało do dyspozycji programisty biblioteki opdowiedzialne za moduł ble oraz moduł odpowiedzialny za sterowanie PWM. Proces generowania jest opisany w [załączonym wcześniej poradniku](https://www.youtube.com/watch?v=2cv_jjqk5hg&list=PLx_tBuQ_KSqEt7NK-H7Lu78lT2OijwIMl). ## Struktura programu Wytworzony program korzysta z trzech specjalnie przygotowanych plików: - `main.c` - `svc.h` - `svc.c` ### `svc.h` i `svc.c` Pliki te zawierają definicję naszego serwisu Bluetooth Low Energy. Serwis ten wystawia 4 charakterystyki typu *Write*. Każda z tych charakterystyk odpowiada za pojedynczą diodę PWM na płytce, patrząc kolejnością po UUID. W celu dostosowania obsługi każdej charakterystyki, należy użyć instancji struktury `bt_led_svc_cbs`, która posiada 4 pola przyjmujące wskaźnik na funkcje zwracającą `void`, przyjmującą jeden argument typu `uint8t`. Następnie należy użyć funkcji `int bt_led_svc_init(struct bt_led_svc_cbs *callbacks)` w celu zarejestrowania własnych funkcji obsługujących poszczególne charakterystyki. ### `main.c` W pliku `main.c` został pokazany przykład użycia napisanego przez nas serwisu bluetooth. Po jego inicjalizacji program działa w pętli, oczekując na przesyłanie danych poprzez wystawione charakterystyki. W naszym przypadku do obsługi charakterystyk napisaliśmy funkcję, która na podstawie otrzymanej wartości zmienia intensywność świecenia diody LED odpowiadającej danej charakterystyce, w skali od 0-100. Odbywa się to za pomocą zawołania funkcji bibliotecznej `led_set_brightness(struct device *dev, uint32_t led, uint8_t value)`. Zakres 0-100 został wybrany, ponieważ większe wartości i tak nie skutkują zintensyfikowaniem światła. Została dodana także specjalną wartość 200, po otrzymaniu której, wybrana dioda rozjaśni się i zgaśnie: 1. zmiana intensywności od wartości `0` do `100` przez sekundę (krok 10 ms) 2. sekunda świecenia z maksymalną jasnością, 3. stopniowa zmiana intensywności od wartości `100` do wartości `0` (krok 10 ms) Pozostałe wartości większe od 100 zostaną sprowadzone do 100. ## Użytkowanie Po kompilacji oraz sflashowaniu programu na płytkę należy oprogramowania do precyzyjnego sterowania połączeniami BLE. My użyliśmy do tego aplikacji nRf Connect. Należy połączyć się z płytką, która nosi nazwę **ZAP_PROJEKT**. Zostanie wyświetlonych kilka standardowych serwisów oraz nasz o UUID `00000001-1212-efde-1523-785feabcd123`. Posiada on 4 charakterystyki, które kolejno oznaczają sterowanie daną diodą. Po wybraniu jednej z nich należy zadbać o to, żeby przesyłana informacja miała typ `UINT8`, w przeciwnym wypadku serwis odrzuci naszą wiadomość. Po poprawnym przesłaniu żądania zobaczymy efekt zależny od wartości, opisany w poprzednim podrozdziale.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully