Code Monkey home page Code Monkey logo

high-voltage's Introduction

OBD/Bluetooth realtime power meter and visualizer for Chevrolet Volt / Opel Ampera cars

Goal: To display a live visualization of the power used (in kW) by the electric drivetrain of the car.

Secondary goals: Add more features and data visualization

Implemented using Re-frame on ClojureScript on Expo on React Native.

Fully functional REPL to a running program on a real device.

All changes immediately visible on the device without recompiling or restarting.

Usage

If you don’t want to use XDE (not IDE, it stands for Expo Development Tools), you can use exp CLI.

Install npm modules

yarn install

Patch react-native-obd2 to newest SDK

  1. edit node_modules/react-native-obd2/android/src/main/java/com/jetbridge/reactobd2/ReactNativeOBD2Package.java
  2. delete method createJSModules()

Install Android SDK, NDK, Platform tools and accept licenses

brew tap homebrew/cask
brew cask install android-ndk
brew cask install android-platform-tools
brew cask install android-sdk

Add env vars to .bashrc / .zshrc:

export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"
export ANDROID_HOME=$ANDROID_SDK_ROOT
export ANDROID_NDK_HOME="/usr/local/share/android-ndk"'

Accept licenses:

sdkmanager --licenses

Install react-native command

npm install -g react-native-cli
react-native link

How to develop with repl and figwheel

XDE

  1. Plug in phone with a USB cable, development powers need to be unlocked.
  2. Open XDE and click “Open existing project…”
  3. Open ‘high-voltage’ project directory
  4. Start the project

Install a debug version of the app to the phone:

cd android
./gradlew installDevMinSdkDevKernelDebug

Start reverse port for figwheel, required for live eval

adb reverse tcp:3449 tcp:3449

nREPL:

lein with-profile dev repl

Connect to nREPL with your $EDITOR and evaluate:

(start-figwheel)

Start the app

On your phone, open Expo. High-voltage should appear on the list. Tap on it.

You’re all set.

From this moment on you only need to save your files in $EDITOR and figwheel will immediately evaluate changes in the running program.

You will also have a fully functional REPL to your program running on your phone. The holy grail of programming.

Notes

Adding native libraries

Libraries requiring linking use ExpoKit

Install ExpoKit:

exp detach

Install and link:

npm install -g react-native-cli
react-native link

Start and run Android project (first run will download the internet):

cd android
./gradlew installDevMinSdkDevKernelDebug

TODOs

Import OBD libs

Connect to actual OBD

Debug window for OBD data

request and visualize power PIDs from OBD using a timer (first phase)

request multiple PIDs from OBD at once using multi query or whatever it was called

Design user interface for selecting adapter

high-voltage's People

Contributors

akaivola avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.