/Moonboard_controllerLED

Code deployed on a STM microcontroller for controlling LED strips mounted on a moonboard. The controls are sent from the moonboard phone app that is connected with STM vie BLE.

Primary LanguageC

IDEA FOR MOONBOARD LED PROJECT

This repository contains the code that I developed for creating a LED moonboard controller. The project is applied on a STM32 microcontroller and it work together with other repositories that I developed. These are:

  • Android app that can be used to filter the moonboard problems, visualize them on the screen and later send the most relevant information via bluetooth to the STM32 microcontroller
  • Python code that I developed for generating the moonboard boulder problems dataset. This uses some computer vision and automatic scrolling throught the problems (on an android simulator installed on the pc) in order to create a json that contains all the info of the boulder problems (because the original dataset is private)

name-of-you-image

UPDATE: Thanks to another GitHub repo that I found (here) I found out how the MoonBoard app actually connects to a device and sends the data. With this the andoird app that I developed becomes pretty much useless and I am currently trying to connect the original app to my STM with a new bluetooth receiver that uses BLE (HM-10). The LED controller part of the code is still usable, while the code for the keypad/LED/bluetooth to my phone becomes obsolete. WORK IN PROGRESS

BOM

The necessary hardware for the STM32 LED controller is:

name-of-you-image

IDEA: Use the custom made app on the phone in order to filter and select the boulder problem. Once the problem has been selected the app displays on screen the used holds (like the original app). At this point the LED can be controlled in two ways. Either by sending via bluetooth the most relevant informations (press the bluetooth button in the app, it will take care of everything) or by using the keypad mounted on the STM case. In this last case the number to insert is the one displayed in the app next to the name. The purpose of the LCD is just for understanding if the problem selected on the STM is correct (name and grade).

GENERAL IDEA OF THE STM CODE

  • The user searches on the app the boulder problem that he want to do. The app will display the problem holds together with the ID
  • The user presses the blue button, this activates the microcontroller to listen for the keypad numbers
  • keypad_GetNumber number gets saved as I insert the digits (press A when finished, press D to delete last digit)
    • polling mode, wait for a key to be pressed, store the digits separately in an array, transform the array in a number, return ID number
  • problem_fetch STM searches the ID just obtained from the keypad in a very big "switch case" that has been filled a priori as a database for the problems
    • the function switch case is copy pasted from a script previously run by a console app on the laptop
    • the function problem_fetch saves in a struct the information of the problem (ID, name, letters and number of the holds, start and top holds, grade)
  • problem_genArray generate a matrix (198x4, row 1=number of the led, row2 = red color, row3 = green color, row4 = blue color) and initializes it to 0 everywhere, then save in the corresponding position the correct colors for the holds used by the problem (holds position is obtained from the struct)
  • WS2811_light sends a PWM signal and lights the leds
    • in a double for cycle, generate an array of values of duty cycles depending on the 0 and 1 bits (from the color array defined previously), send the correct duty cycle data to the PWM peripheral (using DMA)

More detailed explanation of the code developed is in the README in the STM_Moon_LED directory

PHOTOS OF THE CONTROLLER

name-of-you-image

name-of-you-image

DEVICE PIN STM32 PIN DEVICE PIN STM32 PIN
Keypad - row 1 C7 LED line 1 - VDD Wall plug - 5V
Keypad - row 2 A9 LED line 1 - GND Wall plug - GND
Keypad - row 3 A8 LED line 1 - PWM A6
Keypad - row 4 B10 LED line 2 - VDD Wall plug - 5V
Keypad - column 1 B4 LED line 2 - GND Wall plug - GND
Keypad - column 2 B5 LED line 2 - PWM A0
Keypad - column 3 B3 LCD - VDD 5V
Keypad - column 4 A10 LCD - GND GND
HC-05 - VDD 5V LCD - SDA B7
HC-05 - GND GND LCD - SCL B6
HC-05 - TDX C6
HC-05 - RDX A12
HC-05 - Reset B9

The case for the STM32 with the LCD screen, keypad and bluetooth module has been 3d printed. The STL file is contained in the directory 'STL'.

PHOTOS OF THE BOARD

name-of-you-image