[Armadeus-commitlog] armadeus branch, master, updated. armadeus-5.3-296-gf4b9141
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2014-06-23 14:58:49
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via f4b9141b825d14a45b870cea31dea8e29e4e9cb2 (commit)
via 9531013a86e2c557cef3b07dd13291c43db076c6 (commit)
from fb8c0db7277e6010284520558f4ae2d494288ca2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f4b9141b825d14a45b870cea31dea8e29e4e9cb2
Author: Julien Boibessot <jul...@ar...>
Date: Mon Jun 23 16:57:09 2014 +0200
[ASDEVICES] Add C wrappers to drive TCS3472 color converter chips
commit 9531013a86e2c557cef3b07dd13291c43db076c6
Author: Julien Boibessot <jul...@ar...>
Date: Mon Jun 23 16:32:19 2014 +0200
[ASDEVICES] Cleanup
-----------------------------------------------------------------------
Summary of changes:
target/packages/as_devices/Makefile | 31 ++--
target/packages/as_devices/c/Makefile | 25 ++--
target/packages/as_devices/c/as_as1531.c | 9 +-
target/packages/as_devices/c/as_i2c_eeprom.c | 45 ++---
target/packages/as_devices/c/as_max5821.c | 4 -
target/packages/as_devices/c/as_tcs3472.c | 256 ++++++++++++++++++++++++
target/packages/as_devices/c/as_tcs3472.h | 80 ++++++++
target/packages/as_devices/main.c | 11 +-
target/packages/as_devices/test_c.h | 272 ++++++++++++++++++--------
9 files changed, 581 insertions(+), 152 deletions(-)
create mode 100644 target/packages/as_devices/c/as_tcs3472.c
create mode 100644 target/packages/as_devices/c/as_tcs3472.h
diff --git a/target/packages/as_devices/Makefile b/target/packages/as_devices/Makefile
index 7c01bbc..c3cb475 100644
--- a/target/packages/as_devices/Makefile
+++ b/target/packages/as_devices/Makefile
@@ -1,25 +1,23 @@
# Default values for local compiling:
-ARMADEUS_BASE_DIR=../../../
+ARMADEUS_BASE_DIR = ../../../
-include $(ARMADEUS_BASE_DIR)/Makefile.in
-CFLAGS=-Wall -g -O0
+CFLAGS = -Wall -g -O0
LDFLAGS=
-CC:=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc
-CXX:=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-g++
-STRIP:=$(ARMADEUS_TOOLCHAIN_PATH)arm-linux-sstrip
-INSTALL_DIR:=$(ARMADEUS_STAGING_DIR)
+CC = $(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc
+CXX = $(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-g++
+INSTALL_DIR = $(ARMADEUS_STAGING_DIR)
+C_BINARY = test_cdevices
+C_LIBNAME = libas_devices.so
+C_LIB = c/$(C_LIBNAME)
+C_INCLUDE = c
-C_BINARY=test_cdevices
-C_LIBNAME=libas_devices.so
-C_LIB=c/$(C_LIBNAME)
-C_INCLUDE=c
+P_WRAPPER = .python_wrappers
-P_WRAPPER=.python_wrappers
-
-CPP_BINARY=test_cppdevices
-CPP_LIBNAME=libas_devices_cpp.so
-CPP_LIB=cpp/$(CPP_LIBNAME)
-CPP_INCLUDE=cpp
+CPP_BINARY = test_cppdevices
+CPP_LIBNAME = libas_devices_cpp.so
+CPP_LIB = cpp/$(CPP_LIBNAME)
+CPP_INCLUDE = cpp
.PHONY: all install install-exe clean
@@ -55,7 +53,6 @@ install:
install-exe:
install -D $(C_LIB) $(INSTALL_DIR)/usr/lib/$(C_LIBNAME)
- $(STRIP) $(INSTALL_DIR)/usr/lib/$(C_LIBNAME)
clean:
make -C c/ clean
diff --git a/target/packages/as_devices/c/Makefile b/target/packages/as_devices/c/Makefile
index 8ea7426..989b7a5 100644
--- a/target/packages/as_devices/c/Makefile
+++ b/target/packages/as_devices/c/Makefile
@@ -1,10 +1,9 @@
# Default values for local compiling:
-ARMADEUS_BASE_DIR=../../../../
+ARMADEUS_BASE_DIR = ../../../../
-include $(ARMADEUS_BASE_DIR)/Makefile.in
-CFLAGS+= -Wall -g -O0
-LDFLAGS=
-CC:=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc
-STRIP:=$(ARMADEUS_TOOLCHAIN_PATH)arm-linux-sstrip
+CFLAGS ?= -Wall -g -O0
+LDFLAGS =
+CC = $(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc
OBJ += as_pwm.o
OBJ += as_i2c.o
@@ -27,14 +26,15 @@ OBJ += as_backlight.o
OBJ += as_i2c_eeprom.o
OBJ += as_helpers.o
OBJ += as_power_supply.o
+OBJ += as_tcs3472.o
-LIBRARY=as_devices
-LIB_VERS=1
-STAT_LIB=$(LIBRARY).a
-SONAME=lib$(LIBRARY).so
-LIBNAME=$(SONAME).$(LIB_VERS)
-ARCHIVE_CMD=ar
-ARCHIVE_OPTS=-cvq
+LIBRARY = as_devices
+LIB_VERS = 1
+STAT_LIB = $(LIBRARY).a
+SONAME = lib$(LIBRARY).so
+LIBNAME = $(SONAME).$(LIB_VERS)
+ARCHIVE_CMD = ar
+ARCHIVE_OPTS = -cvq
$(LIBNAME): $(OBJ)
@$(CC) -shared -Wl,-soname,$(SONAME) -o $(SONAME) $(OBJ)
@@ -50,4 +50,3 @@ $(STAT_LIB): $(OBJ)
clean:
rm -f $(OBJ) $(BINARY) $(LIBNAME) $(SONAME)
-
diff --git a/target/packages/as_devices/c/as_as1531.c b/target/packages/as_devices/c/as_as1531.c
index 0a74262..8a83bf4 100644
--- a/target/packages/as_devices/c/as_as1531.c
+++ b/target/packages/as_devices/c/as_as1531.c
@@ -12,7 +12,8 @@
#undef ERROR
#define ERROR(fmt, ...) printf(fmt, ##__VA_ARGS__)
-struct as_adc_device *as_adc_open_as1531(int aDeviceNum, int aVRef) {
+struct as_adc_device *as_adc_open_as1531(int aDeviceNum, int aVRef)
+{
struct as_adc_device *dev;
int ret;
int fname;
@@ -51,7 +52,8 @@ struct as_adc_device *as_adc_open_as1531(int aDeviceNum, int aVRef) {
return dev;
}
-int32_t as_adc_get_value_in_millivolts_as1531(struct as_adc_device *aDev, int aChannel) {
+int32_t as_adc_get_value_in_millivolts_as1531(struct as_adc_device *aDev, int aChannel)
+{
int ret;
int finput;
int value;
@@ -78,6 +80,7 @@ int32_t as_adc_get_value_in_millivolts_as1531(struct as_adc_device *aDev, int aC
return (value*aDev->vref)/AS_AS1531_MAX_VALUE;
}
-int32_t as_adc_close_as1531(struct as_adc_device *aDev) {
+int32_t as_adc_close_as1531(struct as_adc_device *aDev)
+{
return 0;
}
diff --git a/target/packages/as_devices/c/as_i2c_eeprom.c b/target/packages/as_devices/c/as_i2c_eeprom.c
index b7a8376..1525cf0 100644
--- a/target/packages/as_devices/c/as_i2c_eeprom.c
+++ b/target/packages/as_devices/c/as_i2c_eeprom.c
@@ -52,8 +52,7 @@ struct as_i2c_eeprom_device * as_i2c_eeprom_open(int aBusNumber,
return NULL;
}
- if (as_i2c_set_slave_addr(i2c_dev, anEeprom_addr) < 0)
- {
+ if (as_i2c_set_slave_addr(i2c_dev, anEeprom_addr) < 0) {
ERROR("Can't set EEPROM address on I2C\n");
return NULL;
}
@@ -69,8 +68,7 @@ struct as_i2c_eeprom_device * as_i2c_eeprom_open(int aBusNumber,
return NULL;
dev = (struct as_i2c_eeprom_device *)malloc(sizeof(struct as_i2c_eeprom_device));
- if (dev == NULL)
- {
+ if (dev == NULL) {
ERROR("Can't allocate memory for I2C eeprom structure device\n");
return NULL;
}
@@ -111,37 +109,33 @@ int32_t as_i2c_eeprom_read(struct as_i2c_eeprom_device *aDev, uint16_t aPage_num
if (aDev->addr_width == 8) {
buffer[0] = 0;
len = 1;
- } else { // 16
+ } else { /* 16 */
buffer[0] = 0;
buffer[1] = 0;
len = 2;
}
- if (as_i2c_set_slave_addr(aDev->i2c_dev, aDev->eeprom_addr) < 0)
- {
+ if (as_i2c_set_slave_addr(aDev->i2c_dev, aDev->eeprom_addr) < 0) {
ERROR("Can't set EEPROM address on I2C\n");
return -1;
}
- if (as_i2c_write(aDev->i2c_dev, buffer, len) < 0)
- {
+ if (as_i2c_write(aDev->i2c_dev, buffer, len) < 0) {
ERROR("Can't write on I2C EEPROM\n");
return -1;
}
- if (as_i2c_set_slave_addr(aDev->i2c_dev, aDev->eeprom_addr|aPage_number) < 0)
- {
+ if (as_i2c_set_slave_addr(aDev->i2c_dev, aDev->eeprom_addr|aPage_number) < 0) {
ERROR("Can't set EEPROM address on I2C\n");
return -1;
}
- if (as_i2c_read(aDev->i2c_dev, buffer, 256) < 0)
- {
+ if (as_i2c_read(aDev->i2c_dev, buffer, 256) < 0) {
ERROR("Can't read on I2C EEPROM\n");
return -1;
}
- memcpy( aBuffer, buffer, 256 );
+ memcpy(aBuffer, buffer, 256);
return 0;
}
@@ -161,8 +155,7 @@ int32_t as_i2c_eeprom_write(struct as_i2c_eeprom_device *aDev, uint16_t aPage_nu
nb_it = aBuffer_size / aDev->page_buffer_size;
int16_t i;
- for (i = 0; i < nb_it; i++)
- {
+ for (i = 0; i < nb_it; i++) {
if (aDev->addr_width == 8) {
buffer[0] = current_pos;
memcpy( buffer+1, aBuffer + current_pos, aDev->page_buffer_size );
@@ -174,14 +167,12 @@ int32_t as_i2c_eeprom_write(struct as_i2c_eeprom_device *aDev, uint16_t aPage_nu
msg_size = aDev->page_buffer_size+2;
}
- if (as_i2c_set_slave_addr(aDev->i2c_dev, aDev->eeprom_addr|aPage_number) < 0)
- {
+ if (as_i2c_set_slave_addr(aDev->i2c_dev, aDev->eeprom_addr|aPage_number) < 0) {
ERROR("Can't set EEPROM address on I2C\n");
return -1;
}
- if (as_i2c_write(aDev->i2c_dev, buffer, msg_size) < 0)
- {
+ if (as_i2c_write(aDev->i2c_dev, buffer, msg_size) < 0) {
ERROR("Can't write on I2C EEPROM\n");
return -1;
}
@@ -215,12 +206,12 @@ static int32_t as_i2c_eeprom_read_write_mid(struct as_i2c_eeprom_device *aDev, u
if (aDev->addr_width == 8) {
addr_len = 1;
- } else { // 16
+ } else { /* 16 */
addr_len = 2;
}
while (aLen) {
- // calculate page and offset
+ /* calculate page and offset */
current_page = current_addr / aDev->page_size;
if (addr_len == 2) {
*((uint16_t*)buffer) = htons(current_addr % aDev->page_size);
@@ -228,13 +219,13 @@ static int32_t as_i2c_eeprom_read_write_mid(struct as_i2c_eeprom_device *aDev, u
*((uint8_t*)buffer) = (uint8_t)(current_addr % aDev->page_size);
}
- // select page to read or write to
+ /* select page to read or write to */
if (as_i2c_set_slave_addr(aDev->i2c_dev, aDev->eeprom_addr|current_page) < 0) {
ERROR("Can't set EEPROM address on I2C\n");
return -1;
}
- // calculate len of fragment regarding page_buffer_size
+ /* calculate len of fragment regarding page_buffer_size */
fragment_len = aDev->page_buffer_size - (current_addr % aDev->page_buffer_size);
if (fragment_len > aLen) {
fragment_len = aLen;
@@ -242,19 +233,19 @@ static int32_t as_i2c_eeprom_read_write_mid(struct as_i2c_eeprom_device *aDev, u
if (isWrite) {
memcpy(buffer + 2, aBuffer, fragment_len);
- // select offset address inside page
+ /* select offset address inside page */
if (as_i2c_write(aDev->i2c_dev, buffer, addr_len + fragment_len) < 0) {
ERROR("Can't write on I2C EEPROM\n");
return -1;
}
usleep(aDev->write_time_us);
} else {
- // select offset address inside page
+ /* select offset address inside page */
if (as_i2c_write(aDev->i2c_dev, buffer, addr_len) < 0) {
ERROR("Can't write on I2C EEPROM\n");
return -1;
}
- // read data
+ /* read data */
if (as_i2c_read(aDev->i2c_dev, aBuffer, fragment_len) < 0) {
ERROR("Can't read on I2C EEPROM\n");
return -1;
diff --git a/target/packages/as_devices/c/as_max5821.c b/target/packages/as_devices/c/as_max5821.c
index 33959b8..ee6c670 100644
--- a/target/packages/as_devices/c/as_max5821.c
+++ b/target/packages/as_devices/c/as_max5821.c
@@ -25,7 +25,6 @@
#include "as_max5821.h"
#include "as_i2c.h"
-
/* command bytes */
#define MAX5821_UPDATE_ALL_DAC_COMMAND (0xE0)
#define MAX5821_EXTENDED_COMMAND_MODE (0xF0)
@@ -36,7 +35,6 @@
#define MAX5821M_MAX_DATA_VALUE (1023)
//#define DEBUG
-
#ifdef DEBUG
# define ERROR(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
@@ -75,8 +73,6 @@ struct as_dac_device *as_dac_open_max5821(int aI2cBus, int aI2cAddress, int aVRe
goto free_dev_err;
}
-
-
max5821_dev->i2c_dev = i2c_dev;
dev->bus_number = aI2cBus;
diff --git a/target/packages/as_devices/c/as_tcs3472.c b/target/packages/as_devices/c/as_tcs3472.c
new file mode 100644
index 0000000..001b95e
--- /dev/null
+++ b/target/packages/as_devices/c/as_tcs3472.c
@@ -0,0 +1,256 @@
+/*
+ * This software is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Julien Boibessot <jul...@ar...>
+ * Copyright (C) 2014 The Armadeus Project & Armadeus Systems
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "as_tcs3472.h"
+
+/* registers */
+#define TCS3472_REG_ENABLE (0x00)
+#define TCS3472_REG_ATIME (0x01)
+#define TCS3472_REG_WTIME (0x02)
+/* TBDL
+#define TCS3472_REG_AILTL (0x04)
+#define TCS3472_REG_AILTH (0x05)
+#define TCS3472_REG_AIHTL (0x06)
+#define TCS3472_REG_AIHTH (0x07)
+#define TCS3472_REG_PERS (0x0c)
+*/
+#define TCS3472_REG_CONFIG (0x0d)
+#define TCS3472_REG_CONTROL (0x0f)
+#define TCS3472_REG_ID (0x12)
+#define TCS3472_REG_STATUS (0x13)
+#define TCS3472_REG_STATUS_AVALID (1 << 0)
+#define TCS3472_REG_CDATAL (0x14)
+#define TCS3472_REG_CDATAH (0x15)
+#define TCS3472_REG_RDATAL (0x16)
+#define TCS3472_REG_RDATAH (0x17)
+#define TCS3472_REG_GDATAL (0x18)
+#define TCS3472_REG_GDATAH (0x19)
+#define TCS3472_REG_BDATAL (0x1a)
+#define TCS3472_REG_BDATAH (0x1b)
+
+//#define DEBUG
+#ifdef DEBUG
+#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
+#else
+#define DBG(fmt, ...) /*fmt, ##__VA_ARGS__ */
+#endif
+#define ERROR(fmt, ...) printf("%s" fmt, __func__, ##__VA_ARGS__)
+
+static int32_t as_tcs3472_read16(struct as_tcs3472 *tcs3472, int reg,
+ unsigned short *value, int size)
+{
+ int ret;
+ unsigned char buf[2];
+
+ /* Set address of register to access */
+ buf[0] = 0x80 | ((unsigned char)(reg & 0x1f));
+ ret = as_i2c_write(tcs3472->i2c_dev, buf, 1);
+ if (ret)
+ return ret;
+
+ /* Read it */
+ ret = as_i2c_read(tcs3472->i2c_dev, buf, 2);
+ if (ret)
+ return ret;
+
+ *value = buf[1] << 8 | buf[0];
+ DBG("read 0x%02x%02x at 0x%02x\n", buf[1], buf[0], reg);
+
+ return 0;
+}
+
+static int32_t as_tcs3472_read8(struct as_tcs3472 *tcs3472, int reg,
+ unsigned char *value)
+{
+ int ret;
+ unsigned char buff[1];
+
+ /* Set address of register to access */
+ buff[0] = 0x80 | ((unsigned char)(reg & 0x1f));
+ ret = as_i2c_write(tcs3472->i2c_dev, buff, 1);
+ if (ret)
+ return ret;
+
+ /* Read it */
+ ret = as_i2c_read(tcs3472->i2c_dev, buff, 1);
+ if (ret)
+ return ret;
+
+ *value = *buff;
+ DBG("read 0x%02x in 0x%02x\n", *value, reg);
+
+ return 0;
+}
+
+static int32_t as_tcs3472_write8(struct as_tcs3472 *tcs3472, int reg,
+ unsigned char value)
+{
+ int ret;
+ unsigned char buf[1];
+
+ /* Set address of register to access */
+ buf[0] = 0x80 | ((unsigned char)(reg & 0x1f));
+ ret = as_i2c_write(tcs3472->i2c_dev, buf, 1);
+ if (ret)
+ return ret;
+
+ /* write value */
+ buf[0] = value;
+ ret = as_i2c_write(tcs3472->i2c_dev, buf, 1);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------*/
+
+struct as_tcs3472 *as_tcs3472_open(int i2c_bus, int i2c_addr)
+{
+ struct as_tcs3472 *tcs3472;
+ struct as_i2c_device *i2c_dev;
+ int ret;
+ unsigned char id;
+
+ i2c_dev = as_i2c_open(i2c_bus);
+ if (i2c_dev == NULL) {
+ perror("Can't open I2C bus number\n");
+ return NULL;
+ }
+
+ ret = as_i2c_set_slave_addr(i2c_dev, i2c_addr);
+ if (ret < 0) {
+ perror("Can't set i2c address\n");
+ goto close_i2c_err;
+ }
+
+ tcs3472 = (struct as_tcs3472 *)malloc(sizeof(struct as_tcs3472));
+ if (!tcs3472) {
+ perror("can't allocate memory for device structure\n");
+ goto close_i2c_err;
+ }
+ tcs3472->i2c_dev = i2c_dev;
+
+ ret = as_tcs3472_read8(tcs3472, TCS3472_REG_ID, &id);
+ if (ret) {
+ printf("%s: can't read ID register !\n", __func__);
+ goto free_tcs3472_dev_err;
+ }
+ if (id == 0x44) {
+ printf("found a TCS34721/5");
+ } else if (id == 0x42) {
+ printf("found a TCS34723/7");
+ } else {
+ printf("No TCS3472x found at given address !!\n");
+ goto free_tcs3472_dev_err;
+ }
+ printf(" @ 0x%02x on I2C%d\n", i2c_addr, i2c_bus);
+
+ /* Powerdown by default */
+ as_tcs3472_write8(tcs3472, TCS3472_REG_ENABLE, 0x00);
+
+ return tcs3472;
+
+free_tcs3472_dev_err:
+ free(tcs3472);
+close_i2c_err:
+ as_i2c_close(i2c_dev);
+ return NULL;
+}
+
+/*-----------------------------------------------------------------------------*/
+
+int32_t as_tcs3472_start_rgbc(struct as_tcs3472 * tcs3472, int time)
+{
+ struct timespec t;
+ unsigned char int_time;
+
+ /* Powerup & wait 24ms */
+ as_tcs3472_write8(tcs3472, TCS3472_REG_ENABLE, 0x01);
+ t.tv_sec = 0;
+ t.tv_nsec = 24000000; /* 24ms */
+ nanosleep(&t, NULL);
+
+ /* Set integration time */
+ int_time = (unsigned char)(256 - (time * 10 / 24));
+ as_tcs3472_write8(tcs3472, TCS3472_REG_ATIME, int_time);
+
+ /* AEN */
+ as_tcs3472_write8(tcs3472, TCS3472_REG_ENABLE, 0x03);
+
+#ifdef DEBUG
+ unsigned char buf2;
+ nanosleep(&t, NULL);
+ as_tcs3472_read8(tcs3472, TCS3472_REG_STATUS, &buf2);
+#endif
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------*/
+
+int32_t as_tcs3472_get_colours(struct as_tcs3472 * tcs3472,
+ struct as_tcs3472_colours * colours)
+{
+ int ret;
+ unsigned short buf;
+ unsigned char status;
+
+ as_tcs3472_read8(tcs3472, TCS3472_REG_STATUS, &status);
+ if (!status && TCS3472_REG_STATUS_AVALID) {
+ ERROR("integration cycle not completed yet\n");
+ return -1;
+ }
+
+ ret = as_tcs3472_read16(tcs3472, TCS3472_REG_CDATAL, &buf, 1);
+ if (ret)
+ return ret;
+ colours->clear = buf;
+
+ ret = as_tcs3472_read16(tcs3472, TCS3472_REG_RDATAL, &buf, 1);
+ if (ret)
+ return ret;
+ colours->red = buf;
+
+ ret = as_tcs3472_read16(tcs3472, TCS3472_REG_GDATAL, &buf, 1);
+ if (ret)
+ return ret;
+ colours->green = buf;
+
+ ret = as_tcs3472_read16(tcs3472, TCS3472_REG_BDATAL, &buf, 1);
+ if (ret)
+ return ret;
+ colours->blue = buf;
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------*/
+
+int32_t as_tcs3472_close(struct as_tcs3472 * tcs3472)
+{
+ as_i2c_close(tcs3472->i2c_dev);
+ free(tcs3472);
+
+ return 0;
+}
diff --git a/target/packages/as_devices/c/as_tcs3472.h b/target/packages/as_devices/c/as_tcs3472.h
new file mode 100644
index 0000000..8065c7e
--- /dev/null
+++ b/target/packages/as_devices/c/as_tcs3472.h
@@ -0,0 +1,80 @@
+/*
+ * This software is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Julien Boibessot <jul...@ar...>
+ * Copyright (C) 2014 The Armadeus Project & Armadeus Systems
+ *
+ */
+
+#ifndef __AS_TCS3472_H__
+#define __AS_TCS3472_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "as_i2c.h"
+
+struct as_tcs3472 {
+ struct as_i2c_device *i2c_dev;
+};
+
+struct as_tcs3472_colours {
+ int clear;
+ int red;
+ int green;
+ int blue;
+};
+
+/** @brief Initialize access to a TCS3472* chip
+ *
+ * @param i2c_bus I2C bus number
+ * @param i2c_addr I2C chip address
+ *
+ * @return as_tcs3472_device structure on success, NULL on error
+ */
+struct as_tcs3472 *as_tcs3472_open(int i2c_bus, int i2c_addr);
+
+/** @brief Start a color convertion
+ *
+ * @param tcs3472 the TCS3472 to ask for
+ * @param time duration of the convertion (integration time)
+ *
+ * @return negative value on error
+ */
+int32_t as_tcs3472_start_rgbc(struct as_tcs3472 *tcs3472, int time);
+
+/** @brief Get R/G/B/C colour components from previous conversion
+ *
+ * @param tcs3472 the TCS3472 to ask for
+ * @param colours pointer to the structure to store the value
+ *
+ * @return negative value on error
+ */
+int32_t as_tcs3472_get_colours(struct as_tcs3472 *tcs3472,
+ struct as_tcs3472_colours *colours);
+
+/** @brief Close TCS3472 access
+ *
+ * @param tcs3472 the chip to close access for
+ *
+ * @return negative value on error
+ */
+int32_t as_tcs3472_close(struct as_tcs3472 *tcs3472);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __AS_TCS3472_H__ */
diff --git a/target/packages/as_devices/main.c b/target/packages/as_devices/main.c
index a87afbf..e1c5053 100644
--- a/target/packages/as_devices/main.c
+++ b/target/packages/as_devices/main.c
@@ -1,8 +1,8 @@
/*
-** THE ARMadeus Systems
+** AsDevices test program
**
-** Copyright (C) 2009 The armadeus systems team
-** Fabien Marteau <fab...@ar...>
+** Copyright (C) 2009-2014 The Armadeus Project & Armadeus Systems teams
+** Author: Fabien Marteau <fab...@ar...>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
@@ -40,13 +40,14 @@ int main(int argc, char ** argv)
printf(" 1) pwm\n");
printf(" 2) i2c\n");
printf(" 3) spi\n");
- printf(" 4) 93LCxx eprom\n");
+ printf(" 4) 93LCxx eeprom\n");
printf(" 5) gpio\n");
printf(" 6) max1027\n");
printf(" 7) max5821\n");
printf(" 8) as1531\n");
printf(" 9) backlight\n");
printf(" a) i2c eeprom\n");
+ printf(" b) tcs3472\n");
printf("> ");
scanf("%s",buffer);
@@ -72,6 +73,8 @@ int main(int argc, char ** argv)
break;
case 'a': test_i2c_eeprom();
break;
+ case 'b': test_tcs3472();
+ break;
default : break;
}
}
diff --git a/target/packages/as_devices/test_c.h b/target/packages/as_devices/test_c.h
index 20ac106..e294806 100644
--- a/target/packages/as_devices/test_c.h
+++ b/target/packages/as_devices/test_c.h
@@ -1,7 +1,8 @@
/*
+ ** AsDevices C layer test program
**
- ** Copyright (C) 2009-2011 The Armadeus Project - ARMadeus Systems
- ** Fabien Marteau <fab...@ar...>
+ ** Copyright (C) 2009-2014 The Armadeus Project & Armadeus Systems teams
+ ** Author: Fabien Marteau <fab...@ar...>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
@@ -15,11 +16,12 @@
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
- **** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h> /* sleep */
#include <math.h>
#include "as_pwm.h"
@@ -33,12 +35,13 @@
#include "as_backlight.h"
#include "as_i2c_eeprom.h"
#include "as_helpers.h"
+#include "as_tcs3472.h"
#define PWM_NUM 0
#define _STR(x) #x
-void pressEnterToContinue(void)
+void press_enter_to_continue(void)
{
printf("\nPress enter to continue\n");
while( getc(stdin) != '\n');
@@ -55,13 +58,12 @@ void test_pwm(void)
struct as_pwm_device *pwm_dev;
pwm_dev = as_pwm_open(PWM_NUM);
- if(pwm_dev == NULL){
+ if (pwm_dev == NULL) {
printf("can't init pwm0\n");
- pressEnterToContinue();
+ press_enter_to_continue();
return;
}
- while(buffer[0] != 'q')
- {
+ while (buffer[0] != 'q') {
system("clear");
printf("*********************************\n");
printf("* Testing pwm menu *\n");
@@ -83,51 +85,51 @@ void test_pwm(void)
case '1' : printf("Give frequency :");
scanf("%d",&value);
as_pwm_set_frequency(pwm_dev,value);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '2' : printf("Current pwm frequency is %d\n",
as_pwm_get_frequency(pwm_dev));
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '3' : printf("Give period :");
scanf("%d", &value);
as_pwm_set_period(pwm_dev, value);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '4' : printf("Current period is %d\n",
as_pwm_get_period(pwm_dev));
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '5' : printf("Give Duty :");
scanf("%d", &value);
as_pwm_set_duty(pwm_dev, value);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '6' : printf("Current Duty is %d\n",
as_pwm_get_duty(pwm_dev));
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '7' : printf("Activate 'a' or Desactivate 'd' ?");
scanf("%s", buffer2);
if (buffer2[0] == 'a') {
as_pwm_set_state(pwm_dev, 1);
printf("Pwm activated\n");
- pressEnterToContinue();
+ press_enter_to_continue();
} else if (buffer2[0] == 'd') {
as_pwm_set_state(pwm_dev, 0);
printf("Pwm desactivated\n");
- pressEnterToContinue();
+ press_enter_to_continue();
} else {
printf("Option %c unknown\n",buffer[0]);
- pressEnterToContinue();
+ press_enter_to_continue();
}
break;
case '8' : if (as_pwm_get_state(pwm_dev)) {
printf("pwm is active\n");
- pressEnterToContinue();
+ press_enter_to_continue();
} else {
printf("pwm is inactive\n");
- pressEnterToContinue();
+ press_enter_to_continue();
}
break;
default : break;
@@ -150,15 +152,13 @@ void test_i2c(void)
struct as_i2c_device *i2c_bus = 0;
int i2c_id = 0;
- while(buffer[0] != 'q')
- {
+ while (buffer[0] != 'q') {
system("clear");
printf("*********************************\n");
printf("* Testing i2c menu *\n");
printf("*********************************\n");
printf("Choose ('q' to quit):\n");
- if (initialized == 0)
- {
+ if (initialized == 0) {
printf(" 1) Open i2c bus \n");
printf(" 2) Change bus number (%d)\n",i2c_id);
} else {
@@ -180,7 +180,7 @@ void test_i2c(void)
printf("Bus %d opened\n", i2c_id);
initialized = 1;
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '2' : printf("Give bus number (max %d): ", sizeof(_STR(AS_I2C_DEV_COUNT))-1);
scanf("%d",&value);
@@ -190,7 +190,7 @@ void test_i2c(void)
} else {
i2c_id = value;
}
- pressEnterToContinue();
+ press_enter_to_continue();
default : break;
}
} else {
@@ -204,7 +204,7 @@ void test_i2c(void)
} else {
initialized = 0;
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
default : break;
}
@@ -216,7 +216,7 @@ void test_i2c(void)
void test_spi(void)
{
printf("TODO\n");
- pressEnterToContinue();
+ press_enter_to_continue();
}
@@ -284,7 +284,7 @@ void test_93LC()
if ( (value != 8) && (value != 16) )
{
printf("Wrong value\n");
- pressEnterToContinue();
+ press_enter_to_continue();
} else {
word_size = value;
}
@@ -299,7 +299,7 @@ void test_93LC()
if ( (value != 46) && (value != 56) && (value != 66) )
{
printf("Wrong value\n");
- pressEnterToContinue();
+ press_enter_to_continue();
} else {
type = value;
}
@@ -318,7 +318,7 @@ void test_93LC()
} else {
initialized = 1;
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
default : break;
}
@@ -328,7 +328,7 @@ void test_93LC()
case '1' : as_93lcxx_close(dev);
printf("eeprom closed\n");
initialized = 0;
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '2' : printf(" Read specific address\n");
printf("Give address in hexadecimal (max 0x%03X):",
@@ -346,7 +346,7 @@ void test_93LC()
printf(" Read %02x at %02X", value2, value );
}
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '3' : printf("Erase specific address\n");
printf("Give address in hexadecimal (max 0x%03X):",
@@ -364,7 +364,7 @@ void test_93LC()
printf("Value erased\n");
}
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '4' : printf("Write specific address\n");
printf("Give address in hexadecimal (max 0x%03X):",
@@ -373,7 +373,7 @@ void test_93LC()
if (value > max_address(type, word_size))
{
printf(" Error, address wrong\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
}
printf("Give value in hexadecimal :");
@@ -383,7 +383,7 @@ void test_93LC()
{
printf("Error, can't write value\n");
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '5' : printf(" Write all\n");
printf("Give value in hexadecimal:");
@@ -393,7 +393,7 @@ void test_93LC()
{
printf("Error, can't write value\n");
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '6' : printf(" Read all\n");
for(i = 0; i <= max_address(type, word_size); i++)
@@ -407,23 +407,23 @@ void test_93LC()
i,as_93lcxx_read(dev, i));
}
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '7' : printf(" Erase all\n");
value = as_93lcxx_erase_all(dev);
if (value < 0)
printf(" Error in erasing eeprom\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '8' : printf("Unlock write\n");
if (as_93lcxx_ewen(dev) < 0)
printf("Error can't unlock write\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '9' : printf("lock write\n");
if (as_93lcxx_ewds(dev) < 0)
printf("Error can't lock write\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
default : break;
}
@@ -458,7 +458,7 @@ void test_gpio()
gpio_dev = as_gpio_open(pin_num);
if (gpio_dev == NULL) {
printf("Error can't open gpio %d\nHave you got gpiolib ?\n", pin_num);
- pressEnterToContinue();
+ press_enter_to_continue();
return ;
}
@@ -494,11 +494,11 @@ void test_gpio()
if (gpio_dev == NULL)
{
printf("Error, can't open %d\n", pin_num);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
}
printf("Ok %d is open\n", pin_num);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '2' : printf("Give direction (in/out) : ");
scanf("%s", buffer);
@@ -506,11 +506,11 @@ void test_gpio()
if (ret < 0)
{
printf("Error, can't change direction\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
}
printf("Ok direction changed\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '3' : printf("Give value : ");
scanf("%d", &value);
@@ -518,21 +518,21 @@ void test_gpio()
if (ret < 0)
{
printf("Error, can't change pin value\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
}
printf("Ok value changed\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '4' : printf("Get value \n");
pin_value = as_gpio_get_pin_value(gpio_dev);
if (pin_value < 0) {
printf("Error, can't get pin value\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
}
printf("Value is %d\n", pin_value);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '5':
printf("rising / falling / both / none\n");
@@ -542,22 +542,22 @@ void test_gpio()
if (ret < 0)
{
printf("Error, can't change irq value\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
}
printf("Ok value changed\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case 'a' : printf("Blocking read (10 sec timeout)\n");
ret = as_gpio_wait_event(gpio_dev, 10000);
if (ret < 0)
{
printf("Error, can't read value\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
}
printf("Value read %d\n",ret);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
default : break;
}
@@ -566,7 +566,7 @@ void test_gpio()
if(ret < 0)
{
printf("Error, can't close gpio\n");
- pressEnterToContinue();
+ press_enter_to_continue();
}
}
@@ -621,7 +621,7 @@ void test_max1027()
printf("Max 1027 device opened\n");
initialized = 1;
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '2' : printf("Give device number:");
scanf("%i",&value);
@@ -632,7 +632,7 @@ void test_max1027()
} else {
devNumber = value;
}
- pressEnterToContinue();
+ press_enter_to_continue();
default : break;
}
}
@@ -648,7 +648,7 @@ void test_max1027()
} else {
initialized = 0;
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '2' : printf("Give wanted Vref (mV): ");
scanf("%f",&fValue);
@@ -656,19 +656,19 @@ void test_max1027()
if (ret < 0)
{
printf("Error, can't close max1027\n");
- pressEnterToContinue();
+ press_enter_to_continue();
}
max1027_dev = as_adc_open(AS_MAX1027_NAME, devNumber, fValue);
if (max1027_dev == NULL){
printf("Error, can't open max1027 with Vref = %fmV\n", fValue);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
}
vRef = fValue;
printf("Vref changed to: %fmV\n", vRef);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '3' : printf("Give channel you want to read (0-6): ");
scanf("%d",&value);
@@ -682,11 +682,11 @@ void test_max1027()
channel);
if (ret < 0) {
printf("Error reading temperature\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
}
printf("Channel %d value read : %dmV\n", channel, ret);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
default : break;
}
@@ -709,10 +709,10 @@ void test_max5821()
if (max5821_dev == NULL)
{
printf("Error, can't open max5821.\n");
- pressEnterToContinue();
+ press_enter_to_continue();
return ;
}
- pressEnterToContinue();
+ press_enter_to_continue();
while(buffer[0] != 'q')
{
@@ -744,7 +744,7 @@ void test_max5821()
{
printf("Error, can't select power mode\n");
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '2' : printf("Choose your mode:\n");
printf(" 0) MAX5821_POWER_UP \n");
@@ -758,7 +758,7 @@ void test_max5821()
{
printf("Error, can't select power mode\n");
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '3' : printf("Give value between 0-1023\n");
printf("> ");
@@ -768,7 +768,7 @@ void test_max5821()
{
printf("Error, can't select value\n");
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '4' : printf("Give value between 0-1023\n");
printf("> ");
@@ -778,7 +778,7 @@ void test_max5821()
{
printf("Error, can't select value\n");
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '5' : printf("Give value between 0-1023\n");
printf("> ");
@@ -788,7 +788,7 @@ void test_max5821()
{
printf("Error, can't select value\n");
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
default : break;
}
@@ -797,7 +797,7 @@ void test_max5821()
ret = as_dac_close(max5821_dev);
if (ret < 0) {
printf("Error on closing max5821_dev\n");
- pressEnterToContinue();
+ press_enter_to_continue();
}
}
@@ -805,7 +805,7 @@ void test_max5821()
void test_as1531(void)
{
printf("TODO\n");
- pressEnterToContinue();
+ press_enter_to_continue();
}
/* Backlight test */
@@ -819,7 +819,7 @@ void test_backlight(void)
backlight_dev = as_backlight_open();
if (backlight_dev == NULL) {
printf("can't init backlight\n");
- pressEnterToContinue();
+ press_enter_to_continue();
return;
}
while (buffer[0] != 'q') {
@@ -838,16 +838,16 @@ void test_backlight(void)
{
case '1' : printf("Actual brightness is %d\n",
as_backlight_get_actual_brightness(backlight_dev));
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '2' : printf("Maximum brightness is %d\n",
as_backlight_get_max_brightness(backlight_dev));
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '3' : printf("Give brightness :");
scanf("%d",&value);
as_backlight_set_brightness(backlight_dev,value);
- pressEnterToContinue();
+ press_enter_to_continue();
break;
default : break;
}
@@ -911,7 +911,7 @@ void test_i2c_eeprom()
if ( (value != 0) && (value != 1) )
{
printf("Wrong value\n");
- pressEnterToContinue();
+ press_enter_to_continue();
} else {
bus_number = value;
printf("Bus number changed to %d\n", bus_number);
@@ -927,7 +927,7 @@ void test_i2c_eeprom()
if ( (value != 8) && (value != 16) )
{
printf("Wrong value\n");
- pressEnterToContinue();
+ press_enter_to_continue();
} else {
addr_width = value;
printf("Eeprom address width changed to %lu\n", addr_width);
@@ -938,7 +938,7 @@ void test_i2c_eeprom()
if ( (value != 16) && (value != 32) )
{
printf("Wrong value\n");
- pressEnterToContinue();
+ press_enter_to_continue();
} else {
page_buffer_size = value;
printf("Page write buffer size changed to %lu\n", page_buffer_size);
@@ -949,7 +949,7 @@ void test_i2c_eeprom()
if ( (value != 1) && (value != 2) && (value != 4) )
{
printf("Wrong value\n");
- pressEnterToContinue();
+ press_enter_to_continue();
} else {
number_pages = value;
printf("Number of pages changed to %d\n", number_pages);
@@ -967,7 +967,7 @@ void test_i2c_eeprom()
} else {
initialized = 1;
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
default : break;
}
@@ -977,7 +977,7 @@ void test_i2c_eeprom()
case '1' : as_i2c_eeprom_close(dev);
printf("eeprom closed\n");
initialized = 0;
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '2' : printf(" Read specific page\n");
printf("Give page number (max. %d):",
@@ -995,7 +995,7 @@ void test_i2c_eeprom()
printf(" Read %s at page %d", page_buffer, value );
}
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
case '3' : printf("Write on specific page\n");
printf("Give page number (max. %d):",
@@ -1004,7 +1004,7 @@ void test_i2c_eeprom()
if (value > number_pages)
{
printf(" Error, wrong page number\n");
- pressEnterToContinue();
+ press_enter_to_continue();
break;
}
printf("Give data to write :");
@@ -1014,7 +1014,7 @@ void test_i2c_eeprom()
{
printf("Error, can't write on page\n");
}
- pressEnterToContinue();
+ press_enter_to_continue();
break;
default : break;
}
@@ -1022,3 +1022,107 @@ void test_i2c_eeprom()
}
}
+void test_tcs3472()
+{
+ char kbd_buf[50];
+
+ /* default values */
+ int i2c_bus = 0;
+ int i2c_addr = 0x29;
+ int convertion_time = 100;
+
+ struct as_tcs3472 *tcs3472;
+ struct as_tcs3472_colours colours;
+ int value, ret, initialized = 0;
+
+ while (kbd_buf[0] != 'q') {
+ system("clear");
+ printf("**********************************\n");
+ printf("* AsDevice TCS3472 Test menu *\n");
+ printf("**********************************\n");
+ printf("Please make your choice ('q' to quit):\n");
+ if (!initialized) {
+ printf(" 1) Change I2C bus (%d)\n", i2c_bus);
+ printf(" 2) Change chip I2C address (0x%02x)\n", i2c_addr);
+ printf(" 3) Initialize TCS3472\n");
+ } else {
+ printf(" 1) Close chip access\n");
+ printf(" 2) Change color convertion time (%dms)\n", convertion_time);
+ printf(" 3) Get colours\n");
+ }
+
+ printf("> ");
+ scanf("%s", kbd_buf);
+
+ if (!initialized) {
+ switch(kbd_buf[0]) {
+ case '1':
+ printf("Give new I2C bus number (0 or 1): ");
+ scanf("%d", &value);
+ if ((value != 0) && (value != 1)) {
+ printf("Wrong value\n");
+ press_enter_to_continue();
+ } else {
+ i2c_bus = value;
+ printf("Bus number changed to %d\n", i2c_bus);
+ }
+ break;
+
+ case '2': printf("Give new I2C address: ");
+ scanf("%d", &value);
+ i2c_addr = value;
+ printf("I2C address changed to 0x%02x\n", i2c_addr);
+ break;
+
+ case '3':
+ tcs3472 = as_tcs3472_open(i2c_bus, i2c_addr);
+ if (!tcs3472) {
+ printf("Failed to open TCS3472 device !\n");
+ initialized = 0;
+ } else {
+ initialized = 1;
+ }
+ press_enter_to_continue();
+ break;
+ }
+ } else { /* initialized */
+ switch (kbd_buf[0]) {
+ case '1':
+ ret = as_tcs3472_close(tcs3472);
+ if (ret) {
+ printf("error while closing\n");
+ } else {
+ printf("TCS3472 access closed\n");
+ initialized = 0;
+ }
+ sleep(1);
+ break;
+
+ case '2':
+ printf("Give new convertion time (ms, max 700): ");
+ scanf("%d", &value);
+ convertion_time = value;
+ if (convertion_time > 700)
+ convertion_time = 700;
+ printf("convertion time changed to %dms\n", convertion_time);
+ sleep(1);
+ break;
+
+ case '3':
+ printf("Launching conversion\n");
+ as_tcs3472_start_rgbc(tcs3472, convertion_time);
+ printf("Waiting end of conversion\n");
+ sleep(1);
+ ret = as_tcs3472_get_colours(tcs3472, &colours);
+ if (ret) {
+ printf("Error, can't get colours\n");
+ } else {
+ printf("C=%04d R=%04d G=%04d B=%04d\n", colours.clear, colours.red, colours.green, colours.blue);
+ }
+ press_enter_to_continue();
+ break;
+ }
+ }
+ }
+}
+
hooks/post-receive
--
armadeus
|