-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 429e926
Showing
13 changed files
with
687 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.sconsign.dblite | ||
.pioenvs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
|
||
# Cache PlatformIO packages | ||
sudo: false | ||
cache: | ||
directories: | ||
- "~/.platformio" | ||
|
||
env: | ||
- PLATFORMIO_CI_SRC=examples/FixedMode | ||
- PLATFORMIO_CI_SRC=examples/ManualMode | ||
- PLATFORMIO_CI_SRC=examples/StandbyFunctionTest | ||
|
||
install: | ||
- pip install -U platformio | ||
|
||
script: | ||
- platformio ci --lib="." --project-conf=platformio.ini | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2016 Hideki Hamada | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Arduino Library For S11059 | ||
|
||
[![Build Status](https://travis-ci.org/jakalada/Arduino-S11059.svg?branch=master)](https://travis-ci.org/jakalada/Arduino-S11059) | ||
|
||
S11059 (A color sensor) library for Arduino. | ||
|
||
## Download | ||
|
||
[download zip file](https://github.com/jakalada/Arduino-S11059/archive/master.zip) | ||
|
||
## Examples | ||
|
||
[please see example code](./examples/FixedMode/FixedMode.ino) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <Wire.h> | ||
#include <S11059.h> | ||
|
||
S11059 colorSensor; | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
colorSensor.begin(); | ||
|
||
// 積分モードを固定時間モードに設定 | ||
colorSensor.setMode(S11059_MODE_FIXED); | ||
|
||
// ゲイン選択 | ||
// * S11059_GAIN_HIGH: Highゲイン | ||
// * S11059_GAIN_LOW: Lowゲイン | ||
colorSensor.setGain(S11059_GAIN_HIGH); | ||
|
||
// 1色あたりの積分時間設定(下記は指定可能な定数ごとの固定時間モードの場合の積分時間) | ||
// * S11059_TINT0: 87.5 us | ||
// * S11059_TINT1: 1.4 ms | ||
// * S11059_TINT2: 22.4 ms | ||
// * S11059_TINT3: 179.2 ms | ||
colorSensor.setTint(S11059_TINT1); | ||
|
||
// ADCリセット、スリープ解除 | ||
if (!colorSensor.reset()) { | ||
Serial.println("reset failed"); | ||
} | ||
|
||
// ADCリセット解除、バスリリース | ||
if (!colorSensor.start()) { | ||
Serial.println("start failed"); | ||
} | ||
} | ||
|
||
void loop() { | ||
// 積分時間よりも長く待機 | ||
// | ||
// 固定時間モード時のS11059.delay()で実行される待機処理の時間は | ||
// S11059.setTint(tint)で設定した値に応じて異なります | ||
colorSensor.delay(); | ||
|
||
// センサのデータ用レジスタ(赤、緑、青、赤外)をまとめてリード | ||
if (colorSensor.update()) { | ||
Serial.print(colorSensor.getRed()); | ||
Serial.print(","); | ||
Serial.print(colorSensor.getGreen()); | ||
Serial.print(","); | ||
Serial.print(colorSensor.getBlue()); | ||
Serial.print(","); | ||
Serial.print(colorSensor.getIR()); | ||
Serial.println(""); | ||
} else { | ||
Serial.println("update failed"); | ||
} | ||
|
||
delay(500); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <Wire.h> | ||
#include <S11059.h> | ||
|
||
S11059 colorSensor; | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
colorSensor.begin(); | ||
|
||
// 積分モードをマニュアル設定モードに設定 | ||
colorSensor.setMode(S11059_MODE_MANUAL); | ||
|
||
// ゲイン選択 | ||
// * S11059_GAIN_HIGH: Highゲイン | ||
// * S11059_GAIN_LOW: Lowゲイン | ||
colorSensor.setGain(S11059_GAIN_LOW); | ||
|
||
// 1色あたりの積分時間設定(下記は指定する定数とマニュアル設定モードの場合の積分時間) | ||
// * S11059_TINT0: 175 us | ||
// * S11059_TINT1: 2.8 ms | ||
// * S11059_TINT2: 44.8 ms | ||
// * S11059_TINT3: 358.4 ms | ||
colorSensor.setTint(S11059_TINT0); | ||
|
||
// マニュアルタイミング(0~65535) | ||
// setTint()で指定した積分時間を何倍まで長くするかを設定 | ||
colorSensor.setManualTiming(3120); | ||
} | ||
|
||
void loop() { | ||
// ADCリセット、スリープ解除 | ||
if (!colorSensor.reset()) { | ||
Serial.println("reset failed"); | ||
} | ||
|
||
// ADCリセット解除、バスリリース | ||
if (!colorSensor.start()) { | ||
Serial.println("start failed"); | ||
} | ||
|
||
// 積分時間よりも長く待機 | ||
// | ||
// マニュアル設定モード時のS11059.delay()で実行される待機処理の時間は | ||
// S11059.setTint(tint)、S11059.setManualTiming(manualTiming)で | ||
// 設定した値に応じて異なります | ||
colorSensor.delay(); | ||
|
||
// 赤、緑、青、赤外データをリード | ||
if (colorSensor.update()) { | ||
Serial.print(colorSensor.getRed()); | ||
Serial.print(","); | ||
Serial.print(colorSensor.getGreen()); | ||
Serial.print(","); | ||
Serial.print(colorSensor.getBlue()); | ||
Serial.print(","); | ||
Serial.print(colorSensor.getIR()); | ||
Serial.println(""); | ||
} else { | ||
Serial.println("update failed"); | ||
} | ||
|
||
delay(1000); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <Wire.h> | ||
#include <S11059.h> | ||
|
||
S11059 colorSensor; | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
colorSensor.begin(); | ||
|
||
colorSensor.setMode(S11059_MODE_FIXED); | ||
colorSensor.setGain(S11059_GAIN_HIGH); | ||
colorSensor.setTint(S11059_TINT3); | ||
if (!colorSensor.reset()) { | ||
Serial.println("reset failed"); | ||
} | ||
|
||
delay(500); | ||
} | ||
|
||
void printValues() { | ||
for (int i = 0; i < 10; i++) { | ||
delay(500); | ||
if (colorSensor.update()) { | ||
Serial.print(colorSensor.getRed()); | ||
Serial.print(","); | ||
Serial.print(colorSensor.getGreen()); | ||
Serial.print(","); | ||
Serial.print(colorSensor.getRed()); | ||
Serial.print(","); | ||
Serial.print(colorSensor.getIR()); | ||
Serial.println(""); | ||
} else { | ||
Serial.println("update(): failed"); | ||
} | ||
} | ||
} | ||
|
||
void loop() { | ||
// 動作が開始され更新されることを確認する | ||
Serial.println("----- not standby"); | ||
if (!colorSensor.start()) { | ||
Serial.println("start(): failed"); | ||
} | ||
Serial.print("isStandby(): "); | ||
Serial.println(colorSensor.isStandby()); | ||
printValues(); | ||
|
||
// 待機モードに入り値が更新されないことを確認する | ||
Serial.println("----- standby"); | ||
if (!colorSensor.standby()) { | ||
Serial.println("standby(): failed"); | ||
} | ||
Serial.print("isStandby(): "); | ||
Serial.println(colorSensor.isStandby()); | ||
printValues(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# KEYWORD1 specifies datatypes | ||
|
||
S11059 KEYWORD1 | ||
|
||
# KEYWORD2 specifies methods and functions | ||
|
||
begin KEYWORD2 | ||
setGain KEYWORD2 | ||
setMode KEYWORD2 | ||
setTint KEYWORD2 | ||
setManualTiming KEYWORD2 | ||
delay KEYWORD2 | ||
reset KEYWORD2 | ||
standby KEYWORD2 | ||
start KEYWORD2 | ||
update KEYWORD2 | ||
isStandby KEYWORD2 | ||
getRed KEYWORD2 | ||
getGreen KEYWORD2 | ||
getBlue KEYWORD2 | ||
getIR KEYWORD2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "S11059", | ||
"description": "A color sensor library for Arduino", | ||
"keywords": "sensor, color", | ||
"authors": | ||
{ | ||
"name": "Hideki Hamada", | ||
"email": "jakalada.net@gmail.com" | ||
}, | ||
"repository": | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/jakalada/Arduino-S11059.git" | ||
}, | ||
"version": "0.0.1", | ||
"url": "https://github.com/jakalada/Arduino-S11059", | ||
"frameworks": "arduino", | ||
"platforms": | ||
[ | ||
"atmelavr", | ||
"espressif" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name=S11059 | ||
version=0.0.1 | ||
author=Hideki Hamada <jakalada.net@gmail.com> | ||
maintainer=Hideki Hamada <jakalada.net@gmail.com> | ||
sentence=A color sensor library for Arduino | ||
paragraph=A color sensor library for Arduino | ||
category=Sensors | ||
url=https://github.com/jakalada/Arduino-S11059 | ||
architectures=* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# | ||
# Project Configuration File | ||
# | ||
# A detailed documentation with the EXAMPLES is located here: | ||
# http://docs.platformio.org/en/latest/projectconf.html | ||
# | ||
|
||
# A sign `#` at the beginning of the line indicates a comment | ||
# Comment lines are ignored. | ||
|
||
# Simple and base environment | ||
# [env:mybaseenv] | ||
# platform = %INSTALLED_PLATFORM_NAME_HERE% | ||
# framework = | ||
# board = | ||
# | ||
# Automatic targets - enable auto-uploading | ||
# targets = upload | ||
|
||
[env:esp12e] | ||
platform = espressif | ||
framework = arduino | ||
board = esp12e | ||
|
||
[env:uno] | ||
platform = atmelavr | ||
framework = arduino | ||
board = uno | ||
|
||
[env:pro16MHzatmega328] | ||
platform = atmelavr | ||
framework = arduino | ||
board = pro16MHzatmega328 |
Oops, something went wrong.