SWIFT, RASPBERRYPI, BLUETOOTH — X — FILE PART 1

Hokuto no Ken punch mania
Hokuto no Ken punch mania

THE “OLD” SYSTEM

  • Adafruit feather BLE
  • 6 ADXL345 accelerometer connected using SPI
  • 6 RGB LED powered by in PWM
  • 6 Punch pad
Punch Pad
Punch Pad
Adafruit Feather
  • C firmware for the Adafruit written with Arduino IDE
  • iOS Application
  • set the sequence
  • set the maximum interval between each color switch
  • be notified about the responses for each hit or miss

HAIL TO THE “NEW” SYSTEM

RaspberryPI 4
  • RaspberryPI
  • 6 RGB LED
  • 6 IR Proximity Sensors
  • 6 Punch Pad
  • Swift software on the Raspberry
  • iOS Application

print(“Hello RASPBERRY”)

curl -s https://packagecloud.io/install/repositories/swift-arm/release/script.deb.sh | sudo bash
sudo apt install swiftlang

THE MISSING IDE

curl -s https://packagecloud.io/install/repositories/swift-arm/vscode/script.deb.sh | sudo bashsudo apt install code
  • Swift Language
  • CodeLLDB
Swift Language VSCode Plugin
Swift Language VSCode Plugin
CodeLLDB VSCode plugin
CodeLLDB VSCode plugin

GPIO or GPIE?

GPIO Scheme
GPIO Scheme
GPIO Configuration
GPIO Configuration

IS BLUETOOH ON RASPBERRY A BLUEBERRY?

DEBUGGIN’

swift build 
lldb .build/debug/your-exec-name
breakpoint set -f file-name.swift -l 34
  • launch.json
  • task.json
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/.build/debug/RaspberryBLE",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "Build"
}
]
}
{
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "swift build"
}
]
}
Debug interface in VSCode
Debug interface in VSCode

THE SUDO PROBLEM

pi@raspberrypi:~/Desktop/RaspberryBLE/PunchBLE sudo code . --user-data-dir=’~/.vscode-root’ --no-sandbox

THE RUN LOOP

  • create a main queue using dispatchMain()
  • create a run loop usingRunLoop

THE SOFTWARE

The software running

WHAT’ S NEXT

REFERENCES

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store