Skip to content

Commit

Permalink
Update to the latest nimble requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
xyz32 committed May 22, 2017
1 parent 21cc4b1 commit bf62d11
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 84 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ nimcache/

bonegpio

# .kdev4/
# *.kdev4
.kdev4/
#*.kdev4

# Swap Files #
.*.kate-swp
Expand Down
50 changes: 0 additions & 50 deletions .kdev4/boneGPIO.kdev4

This file was deleted.

12 changes: 6 additions & 6 deletions boneGPIO.kdev4 → boneIO.kdev4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Project]
Name=boneGPIO
Name=boneIO
Manager=KDevCustomBuildSystem
VersionControl=

Expand All @@ -11,10 +11,10 @@ BuildDir=
Title=Release

[CustomBuildSystem][BuildConfig0][ToolBuild]
Arguments=build
Arguments=build -y
Enabled=true
Environment=
Executable=nimble
Executable=file:nimble
Type=0

[CustomBuildSystem][BuildConfig0][ToolClean]
Expand All @@ -28,14 +28,14 @@ Type=3
Arguments=init
Enabled=true
Environment=
Executable=minble
Executable=file:minble
Type=1

[CustomBuildSystem][BuildConfig0][ToolInstall]
Arguments=install
Arguments=install -y
Enabled=true
Environment=
Executable=nimble
Executable=file:nimble
Type=2

[CustomBuildSystem][BuildConfig0][ToolPrune]
Expand Down
6 changes: 3 additions & 3 deletions boneGPIO.nimble → boneIO.nimble
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[Package]
name = "boneGPIO"
version = "0.6.0"
name = "boneIO"
version = "0.6.1"
author = "Radu Oana"
description = "Beagle bone black GPIO implementation"
license = "MIT"

srcDir = "src"

[Deps]
Requires: "nim >= 0.12.0"
Requires: "nim >= 0.17.0"
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/bone/adc.nim → src/boneIO/adc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# OTHER DEALINGS IN THE SOFTWARE.
#
#
import bone, os, bone/cape, strutils
import boneIO, os, boneIO/cape, strutils

const
capeName = "cape-bone-iio"
Expand All @@ -32,7 +32,7 @@ const
proc pinModeADC* (pin: string) =
## Enable the ADC mode for the pin

if bone.hasADC(pin):
if boneIO.hasADC(pin):
cape.enable(capeName) #Make sure the pwm controller is enabled
else:
raise newException(ValueError, "Pin '" & pin & "' does not support ADC")
Expand All @@ -42,6 +42,6 @@ proc pinModeADC* (pin: string) =
proc analogRead* (pin: string): int =
## Read analogic data form ADC pin.

let adcNo = bone.getPinData(pin).ain
let adcNo = boneIO.getPinData(pin).ain
result = parseInt(strip(cape.readFile(adcPinFile % [$adcNo]), true, true))
#end
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 16 additions & 16 deletions src/bone/gpio.nim → src/boneIO/gpio.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#
#

import bone, os, strutils
import boneIO, os, strutils

type
## Pin direction, in or out
Expand Down Expand Up @@ -75,11 +75,11 @@ proc pinMode* (pin: string, direction: Direction, pullup: PullUpDown = PullUpDow
## Set the pin mod

# LEDs need to be treated differently
if bone.hasLED(pin):
let pinLed = $bone.getPinData(pin).led
if boneIO.hasLED(pin):
let pinLed = $boneIO.getPinData(pin).led
writeFile(ledTriggerFile % [pinLed], "gpio")
else:
let pinGpio = $bone.getPinData(pin).gpio;
let pinGpio = $boneIO.getPinData(pin).gpio;
exportPin(pinGpio)
setPinDirection(pinGpio, direction)
#end
Expand All @@ -88,42 +88,42 @@ proc pinMode* (pin: string, direction: Direction, pullup: PullUpDown = PullUpDow
proc pinModeReset* (pin: string) =
## Reset the pin mode

exportPin($bone.getPinData(pin).gpio, false)
exportPin($boneIO.getPinData(pin).gpio, false)
#end

proc digitalWrite* (pin: string, value: int) =
if bone.hasLED(pin):
let pinLed = $bone.getPinData(pin).led
if boneIO.hasLED(pin):
let pinLed = $boneIO.getPinData(pin).led
writeFile(ledBrightnessFile % [pinLed], $value)
else:
let pinGpio = $bone.getPinData(pin).gpio
let pinGpio = $boneIO.getPinData(pin).gpio
writeFile(gpioValueFile % [pinGpio], $value)
#end
#end

proc digitalRead* (pin: string): int =
if bone.hasLED(pin):
let pinLed = $bone.getPinData(pin).led
if boneIO.hasLED(pin):
let pinLed = $boneIO.getPinData(pin).led
result = int(parseInt(readFile(ledBrightnessFile % [pinLed])))
else:
let pinGpio = $bone.getPinData(pin).gpio
let pinGpio = $boneIO.getPinData(pin).gpio
result = int(parseInt(readFile(gpioValueFile % [pinGpio])))
#end
#end

# Testing
when isMainModule:
assert(bone.getPinData("P8_3").key == "P8_3")
assert(boneIO.getPinData("P8_3").key == "P8_3")
try:
discard bone.getPinData("bla").key
discard boneIO.getPinData("bla").key
except ValueError:
assert (true)
#end

assert ($bone.getPinData("P9_42").eeprom == "4")
assert ($boneIO.getPinData("P9_42").eeprom == "4")

try:
discard bone.getPinData("P9_46").gpio
discard boneIO.getPinData("P9_46").gpio
except ValueError:
assert (true)
#end
Expand All @@ -139,4 +139,4 @@ when isMainModule:

pinModeReset("USR0")
#end
#end
#end
File renamed without changes.
2 changes: 1 addition & 1 deletion src/bone/i2c.nim → src/boneIO/i2c.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#
# http://elinux.org/Interfacing_with_I2C_Devices#Beagleboard_I2C2_Enable

import bone, bone/cape, strutils, os, posix
import boneIO, boneIO/cape, strutils, os, posix

const
i2cDevFile = "/dev/i2c-$1"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/bone/pwm.nim → src/boneIO/pwm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#

#http://elinux.org/EBC_Exercise_13_Pulse_Width_Modulation
import bone, bone/cape, strutils, os
import boneIO, boneIO/cape, strutils, os

const
capeName = "am33xx_pwm"
Expand All @@ -44,7 +44,7 @@ proc setFreqHz* (pin: string, freqHz: int) =

proc pinModePWM* (pin: string) =
## Set the Pin in PWM mode
if bone.hasPWM(pin):
if boneIO.hasPWM(pin):
cape.enable(capeName) #Make sure the pwm controller is enabled
cape.waitForCape(capeName)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/bone/servo.nim → src/boneIO/servo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#
#

import bone/pwm
import boneIO/pwm

type
Servo = object
Expand Down
File renamed without changes.

0 comments on commit bf62d11

Please sign in to comment.