Explorar o código

next try with burst scans

Zoadian %!s(int64=11) %!d(string=hai) anos
pai
achega
243c211158

+ 0 - 2
Visual Micro/.drumduino_firmware.vsarduino.h

@@ -42,8 +42,6 @@ extern "C" void __cxa_pure_virtual() {;}
 inline void setPrescalers(byte i);
 inline void multiplexSelectChan(uint8_t chan);
 //
-inline void handleMessage(byte* msg, byte length);
-inline void input();
 inline void output();
 //
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
Visual Micro/Compile.vmps.xml


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
Visual Micro/Configuration.Release.vmps.xml


+ 46 - 43
drumduino_firmware.ino

@@ -21,7 +21,7 @@ inline void setPrescalers(byte i)
 	};
 
 	ADCSRA &= ~prescalers[6];
-	ADCSRA |= prescalers[0];
+	ADCSRA |= prescalers[2];
 }
 
 inline void multiplexSelectChan(uint8_t chan)
@@ -32,6 +32,7 @@ inline void multiplexSelectChan(uint8_t chan)
 struct SysexFrame {
 	byte begin;
 	byte manufacturer;
+	unsigned long time;
 	byte values[CHAN_CNT* PORT_CNT];
 	byte end;
 
@@ -45,8 +46,6 @@ struct SysexFrame {
 };
 
 SysexFrame _frame;
-byte _throttle = 1;
-byte _cnt = 0;
 
 void setup()
 {
@@ -66,37 +65,39 @@ void setup()
 	setPrescalers(2);
 }
 
-inline void handleMessage(byte* msg, byte length)
-{
-	switch(msg[0] && length == 3) {
-		case 0xff: {
-			setPrescalers(msg[1]);
-			_throttle = msg[2] != 0 ? msg[2] : 1;
-		}
-	}
-}
-
-inline void input()
-{
-	//read until we receive a sysex
-	while(Serial.peek() >= 0 && Serial.peek() != 0xF0) {
-		Serial.read();
-	}
-
-	if(Serial.available() >= 6) {
-		byte start = Serial.read();
-		byte manufacturerId = Serial.read();
-		byte deviceId = Serial.read();
-		byte length = Serial.read();
-		byte value[128];
-
-		if(length > 0) {
-			Serial.readBytes(value, length);
-			handleMessage(value, length);
-		}
-	}
-}
-
+//inline void handleMessage(byte* msg, byte length)
+//{
+//	switch(msg[0] && length == 3) {
+//		case 0xff: {
+//			setPrescalers(msg[1]);
+//			_throttle = msg[2] != 0 ? msg[2] : 1;
+//		}
+//	}
+//}
+//
+//inline void input()
+//{
+//	//read until we receive a sysex
+//	while(Serial.peek() >= 0 && Serial.peek() != 0xF0) {
+//		Serial.read();
+//	}
+//
+//	if(Serial.available() >= 6) {
+//		byte start = Serial.read();
+//		byte manufacturerId = Serial.read();
+//		byte deviceId = Serial.read();
+//		byte length = Serial.read();
+//		byte value[128];
+//
+//		if(length > 0) {
+//			Serial.readBytes(value, length);
+//			handleMessage(value, length);
+//		}
+//	}
+//}
+
+
+#define BURST_CNT 5
 
 inline void output()
 {
@@ -109,22 +110,24 @@ inline void output()
 
 			byte& value = *(_frame.values + channelNumber);
 
-			byte v = byte(analogRead(port) >> 3); //map [0..1023] -> [0..127]
+			value = 0;
 
-			value = (value > v) ? value : v;
-		}
-	}
+			for(uint8_t burst = 0; burst < BURST_CNT; ++burst) {
+				byte v = byte(analogRead(port) >> 3);
 
-	if(_cnt % _throttle == 0) {
-		Serial.write((byte*)&_frame, sizeof(_frame));
-		memset(_frame.values, 0, sizeof(_frame.values));
+				if(v > value) {
+					value = v;
+				}
+			}
+		}
 	}
 
-	++_cnt;
+	_frame.time = millis();
+	Serial.write((byte*)&_frame, sizeof(_frame));
 }
 
 void loop()
 {
-	input();
+	//input();
 	output();
 }

+ 5 - 1
drumduino_firmware.vcxproj

@@ -56,11 +56,15 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <WarningLevel>Level3</WarningLevel>
-      <Optimization>MaxSpeed</Optimization>
+      <Optimization>Disabled</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <SDLCheck>true</SDLCheck>
       <AdditionalIncludeDirectories>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino;C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard;C:\Program Files (x86)\Arduino\libraries;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries;C:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\default\debuggers;C:\Users\micro_000\Documents\Arduino\libraries;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\;c:\program files (x86)\arduino\hardware\tools\avr\avr\;c:\program files (x86)\arduino\hardware\tools\avr\lib\gcc\avr\4.3.2\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <ForcedIncludeFiles>C:\Users\micro_000\Desktop\github\drumduino_firmware\Visual Micro\.drumduino_firmware.vsarduino.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
+      <IgnoreStandardIncludePath>true</IgnoreStandardIncludePath>
+      <WholeProgramOptimization>false</WholeProgramOptimization>
+      <PreprocessorDefinitions>__AVR_ATmega328p__;__AVR_ATmega328P__;ARDUINO=156;ARDUINO_MAIN;__AVR__;__avr__;F_CPU=16000000L;__cplusplus;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio