add exponential

This commit is contained in:
Harald Pichler 2016-01-25 22:39:52 +01:00
parent f2fe41017b
commit c09625704c
2 changed files with 7 additions and 5 deletions

View file

@ -15,7 +15,7 @@ CONTIKI_WITH_IPV6 = 1
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
PROJECT_SOURCEFILES += ${SKETCH}.cpp klin.c
PROJECT_SOURCEFILES += ${SKETCH}.cpp kexp.c
# automatically build RESTful resources
REST_RESOURCES_DIR = ./resources

View file

@ -13,7 +13,7 @@
extern "C" {
#include "rest-engine.h"
#include "dev/servo.h"
#include "klin.h" // linera values lookup table
#include "kexp.h" // exponential values lookup table
extern resource_t res_poti, res_battery;
uint8_t poti_pin = A5;
@ -53,9 +53,11 @@ void setup (void)
void loop (void)
{
int value;
int vlookup;
poti_voltage = analogRead(poti_pin);
value=scale (345,868,servo_min,servo_max,poti_voltage);
uint16_t lookup_Daumengas(uint16_t i);
servo_set(1,lookup_Daumengas(value));
printf("%d,%d\n",poti_voltage,value);
vlookup=lookup_Daumengas(value-servo_min)+servo_min;
servo_set(1,vlookup);
// servo_set(1,value);
printf("%d,%d,%d\n",poti_voltage,value,vlookup);
}