From 42a38959ff5c097463c2c95d993e5934f100d223 Mon Sep 17 00:00:00 2001 From: sicarius Date: Mon, 19 Feb 2007 20:57:03 +0000 Subject: Code-stuff --- source/Concept/Framework/modules/input/distance_sensor.c | 12 ++++++------ source/Concept/Framework/modules/input/mouse_sensor.h | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'source/Concept/Framework/modules/input') diff --git a/source/Concept/Framework/modules/input/distance_sensor.c b/source/Concept/Framework/modules/input/distance_sensor.c index 977784f..508eeed 100755 --- a/source/Concept/Framework/modules/input/distance_sensor.c +++ b/source/Concept/Framework/modules/input/distance_sensor.c @@ -9,24 +9,24 @@ float Distance_Sensor::GetDistance() *hardwareDDR |= pin;//Set pin output *hardwarePort |= pin;//Activate port usleep(10);//Wait for 10µs - //*hardwarePort &= ~pin;//Deactivate port + *hardwarePort &= ~pin;//Deactivate port *hardwareDDR &= ~pin;//Set pin input - (parent->GetModule(IO_DISPLAY_MAIN))->Print("pre 1", 4, 1); + //(parent->GetModule(IO_DISPLAY_MAIN))->Print("pre 1", 4, 1); //Wait for response - while(!(PINC & pin)){asm volatile("nop");} + for(int i=0;(!(PINC & pin))&&(i < 1000);i++) {asm volatile("nop");} - (parent->GetModule(IO_DISPLAY_MAIN))->Print("pre 2", 4, 1); + //(parent->GetModule(IO_DISPLAY_MAIN))->Print("pre 2", 4, 1); //Calculate duration of response - while(*hardwarePin & pin) + while((*hardwarePin & pin)&&(result < 300000)) { result++; asm volatile("nop"); } - (parent->GetModule(IO_DISPLAY_MAIN))->Print("pre 3", 4, 1); + //(parent->GetModule(IO_DISPLAY_MAIN))->Print("pre 3", 4, 1); return (float(result) * DISTANCE_PER_VALUE); } diff --git a/source/Concept/Framework/modules/input/mouse_sensor.h b/source/Concept/Framework/modules/input/mouse_sensor.h index 30f9d53..460e387 100755 --- a/source/Concept/Framework/modules/input/mouse_sensor.h +++ b/source/Concept/Framework/modules/input/mouse_sensor.h @@ -42,9 +42,9 @@ public: this->pinSCK = (1 << 6); this->registerConfig = 0x00; this->registerPixelData = 0x08; - this->registerSqual = 0x4; - this->registerDeltaX = 0x3; - this->registerDeltaY = 0x2; + this->registerSqual = 0x04; + this->registerDeltaX = 0x03; + this->registerDeltaY = 0x02; this->configReset = 0x80; this->configAwake = 0x01; break; @@ -52,13 +52,13 @@ public: this->hardwarePort = &PORTC; this->hardwareDDR = &DDRC; this->hardwarePin = &PINC; - this->pinSDA = (1 << 5); - this->pinSCK = (1 << 7); + this->pinSDA = (1 << 7); + this->pinSCK = (1 << 5); this->registerConfig = 0x00; this->registerPixelData = 0x08; - this->registerSqual = 0x4; - this->registerDeltaX = 0x3; - this->registerDeltaY = 0x2; + this->registerSqual = 0x04; + this->registerDeltaX = 0x03; + this->registerDeltaY = 0x02; this->configReset = 0x80; this->configAwake = 0x01; break; -- cgit v1.2.3