ROVER - Previous, deprecated API deleted
Signed-off-by: Mustafa Ozcelikors <mozcelikors@gmail.com>
diff --git a/rover/include/api/basic_psys_rover.h b/rover/include/api/basic_psys_rover.h
deleted file mode 100644
index 8c069f6..0000000
--- a/rover/include/api/basic_psys_rover.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2016 Eclipse Foundation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors:
- * Gaël Blondelle - initial API and parameters
- * Contributors:
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <wiringPi.h>
-
-#ifndef PSYS_ROVER_H_
-#define PSYS_ROVER_H_
-
-#define FORWARD 1
-#define BACKWARD -1
-#define LEFT 1
-#define RIGHT 2
-#define DEFAULT_DELAY 450
-
-#define FULL_SPEED 480
-#define LOW_SPEED 360
-
-#define DIRECTION_PIN_LEFT 5 // Physical 18
-#define SOFT_PWM_ENGINE_LEFT 26 // Physical 32
-#define ENABLE_MOTOR_LEFT 3 // Physical 15
-#define DIRECTION_PIN_RIGHT 6 // Physical 22
-#define SOFT_PWM_ENGINE_RIGHT 23 // Physical 33
-#define ENABLE_MOTOR_RIGHT 4 // Physical 16
-#define FLASH_LIGHT_LED 7 // Physical 7
-
-#define LED_FLEFT 4 // Physical 16
-#define LED_FRIGHT 5 // Physical 18
-#define DISTANCE 6 // Physical 22
-
-// Analog sensors
-#define BASE 200
-#define SPI_CHAN 0
-
-extern void init(void);
-
-extern void stop(void);
-
-extern void shutdown_rover(void);
-
-extern void go(int direction, int speed);
-
-extern void turn(int direction, int side, int speed);
-
-extern void turnOnSpot (int direction, int side, int speed);
-
-extern void toggle_light(void);
-
-extern float getDistance(int channel);
-
-extern float getTemperature(void);
-
-extern float getHumidity(void);
-
-extern void runside(int side, int direction, int speed);
-
-
-#endif /* PSYS_ROVER_H_ */
-
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/rover/src/api/basic_psys_rover.c b/rover/src/api/basic_psys_rover.c
deleted file mode 100644
index 0cdba9b..0000000
--- a/rover/src/api/basic_psys_rover.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 2016 Eclipse Foundation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors:
- * Gaël Blondelle - initial implementation
- * Contributors:
- */
-
-#include <wiringPi.h>
-#include <mcp3004.h>
-#include <softPwm.h>
-#include <wiringPiI2C.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <api/basic_psys_rover.h>
-
-static int led_status = 0;
-static int i2c_th02_fd = 0;
-
-void init(){
- //wiringPiSetup () ;
-
- pinMode (ENABLE_MOTOR_LEFT, OUTPUT) ;
- digitalWrite (ENABLE_MOTOR_LEFT, HIGH) ;
- pinMode (ENABLE_MOTOR_RIGHT, OUTPUT) ;
- digitalWrite (ENABLE_MOTOR_RIGHT, HIGH) ;
- pinMode (DIRECTION_PIN_LEFT, OUTPUT) ;
- pinMode (DIRECTION_PIN_RIGHT, OUTPUT) ;
-
-
- softPwmCreate (SOFT_PWM_ENGINE_LEFT, 0, FULL_SPEED) ;
- softPwmCreate (SOFT_PWM_ENGINE_RIGHT, 0, FULL_SPEED) ;
-
- pinMode (FLASH_LIGHT_LED, OUTPUT) ;
-
-// Init the analog digital converter
- mcp3004Setup (BASE, SPI_CHAN); // 3004 and 3008 are the same 4/8 channels
-
-// Init the I2C interface for device 0x40 which is the id of the temperature/humidity sensor
- i2c_th02_fd = wiringPiI2CSetup (0x40);
-}
-
-float getDistance(int channel){
- float x;
- float y=analogRead (BASE+channel);
-
-// 1/cm to output voltage is almost linear between
-// 80cm->0,4V->123
-// 6cm->3,1V->961
-// => y=5477*x+55 => x= (y-55)/5477
- if (y<123){
- x=100.00;
- } else {
- float inverse = (y-55)/5477;
- printf("inverse=%f\n",inverse);
- // x is the distance in cm
- x = 1/inverse;
- }
-
- printf("Distance channel row data %d:%f\n",channel,y);
- printf("Distance channel (cm) %d:%f\n",channel,x);
-
- return x;
-}
-
-float getTemperature(){
- float x;
-
- unsigned char command[2]= {0};
-
- command[0]=0x03;
- command[1]=0x11;
-
- printf("fd:%d\n",i2c_th02_fd);
-
-// wiringPiI2CWriteReg8(i2c_th02_fd, 0x03, 0x01);
-
- write(i2c_th02_fd,command,2);
-
- // Poll RDY (D0) in STATUS (register 0) until it is low (=0)
- int status = -1;
- delay (30);
- while ((status & 0x01) != 0) {
- status = wiringPiI2CReadReg8(i2c_th02_fd,0);
- printf("Status:%d\n",status);
- }
-
- // Read the upper and lower bytes of the temperature value from
- // DATAh and DATAl (registers 0x01 and 0x02), respectively
- unsigned char buffer[3]= {0};
- read(i2c_th02_fd, buffer, 3);
-
- int dataH = buffer[1] & 0xff;
- int dataL = buffer[2] & 0xff;
-
-// int dataH = wiringPiI2CRead(i2c_th02_fd)&0xff;
-// int dataL = wiringPiI2CRead(i2c_th02_fd)&0xff;
- printf("dataH:%02X\n",dataH);
- printf("dataL:%02X\n",dataL);
-
- x = (dataH * 256 + dataL) >> 2;
- printf("Temperature raw:%d\n",(int)x);
- x = (x / 32) - 50;
-
- printf("Temperature:%f\n",x);
-
- return x;
-}
-
-float getHumidity(){
- float x;
-
- unsigned char command[2]= {0};
-
- command[0]=0x03;
- command[1]=0x01;
-
- printf("fd:%d\n",i2c_th02_fd);
-
-// wiringPiI2CWriteReg8(i2c_th02_fd, 0x03, 0x01);
-
- write(i2c_th02_fd,command,2);
-
- // Poll RDY (D0) in STATUS (register 0) until it is low (=0)
- int status = -1;
- delay (30);
- while ((status & 0x01) != 0) {
- status = wiringPiI2CReadReg8(i2c_th02_fd,0);
- printf("Status:%d\n",status);
- }
-
- // Read the upper and lower bytes of the temperature value from
- // DATAh and DATAl (registers 0x01 and 0x02), respectively
- unsigned char buffer[3]= {0};
- read(i2c_th02_fd, buffer, 3);
-
- int dataH = buffer[1] & 0xff;
- int dataL = buffer[2] & 0xff;
-
-// int dataH = wiringPiI2CRead(i2c_th02_fd)&0xff;
-// int dataL = wiringPiI2CRead(i2c_th02_fd)&0xff;
- printf("dataH:%02X\n",dataH);
- printf("dataL:%02X\n",dataL);
-
- x = (dataH * 256 + dataL) >> 4;
- printf("Humidity raw:%d\n",(int)x);
- x = (x / 16) - 24;
-
- printf("Humidity:%f\n",x);
-
- return x;
-}
-
-void runside(int side, int direction, int speed){
- // POLOLU_2756
- if (side==LEFT){
- if (direction>0) {
- digitalWrite (DIRECTION_PIN_LEFT, HIGH) ;
-
- } else if (direction<0) {
- digitalWrite (DIRECTION_PIN_LEFT, LOW) ;
- } else return;
- softPwmWrite (SOFT_PWM_ENGINE_LEFT, speed) ;
- } else if (side==RIGHT){
- if (direction>0) {
- digitalWrite (DIRECTION_PIN_RIGHT, HIGH) ;
-
- } else if (direction<0) {
- digitalWrite (DIRECTION_PIN_RIGHT, LOW) ;
- } else return;
- softPwmWrite (SOFT_PWM_ENGINE_RIGHT, speed) ;
- }
-}
-
-
-
-void go (int direction, int speed){
- runside (LEFT, direction, speed);
- runside (RIGHT, direction, speed);
-
- //delay (DEFAULT_DELAY) ;
-}
-
-void turn (int direction, int side, int speed){
- if (side==LEFT){
-// runside (LEFT, -direction, speed);
- runside (LEFT, direction, 0);
- runside (RIGHT, direction, speed);
- }
- if (side==RIGHT){
- runside (LEFT, direction, speed);
-// runside (RIGHT, -direction,speed);
- runside (RIGHT, direction, 0);
- }
- //delay (DEFAULT_DELAY) ;
-}
-
-void turnOnSpot (int direction, int side, int speed){
- if (side==LEFT){
- runside (RIGHT, -direction, speed);
-// runside (LEFT, direction, 0);
- runside (LEFT, direction, speed);
- }
- if (side==RIGHT){
- runside (RIGHT, direction, speed);
- runside (LEFT, -direction,speed);
-// runside (RIGHT, direction, 0);
- }
- //delay (DEFAULT_DELAY) ;
-}
-
-
-void shutdown(){
- softPwmStop(SOFT_PWM_ENGINE_LEFT) ;
- softPwmStop(SOFT_PWM_ENGINE_RIGHT) ;
-}
-
-
-void stop(){
- runside (LEFT, FORWARD,0);
- runside (RIGHT, FORWARD,0);
-}
-
-void toggle_light(){
- digitalWrite (FLASH_LIGHT_LED, ++led_status % 2) ;
-}