switched bit to long.
started speeding things up. working on code timing. Fixed the bit shift in the for loop.
This commit is contained in:
14
src/main.cpp
14
src/main.cpp
@@ -3,14 +3,14 @@
|
||||
#include <util/delay.h>
|
||||
|
||||
//32 bit code
|
||||
int code = 0b11111111100000000111111011100001;
|
||||
long code = 0b11111111100000000111111011100001;
|
||||
|
||||
//length of each bit
|
||||
#define BIT_LENGTH 10
|
||||
#define BIT_LENGTH 1
|
||||
|
||||
//Generates the carrier requency for the supplied timeframe
|
||||
void carrier(int BlastTime) {
|
||||
for(int i=0; i<(BlastTime / 2); i++)
|
||||
for(int i=0; i<(BlastTime); i++)
|
||||
{
|
||||
PORTB |= (1 << 0x04);
|
||||
_delay_ms(BIT_LENGTH);
|
||||
@@ -29,9 +29,9 @@ int sendShort(void){
|
||||
|
||||
// send '0/ bit
|
||||
int sendLong(void){
|
||||
_delay_ms(BIT_LENGTH);
|
||||
_delay_ms(BIT_LENGTH*2);
|
||||
carrier(BIT_LENGTH);
|
||||
_delay_ms(BIT_LENGTH);
|
||||
_delay_ms(BIT_LENGTH*2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ void sendBlast(void) {
|
||||
|
||||
//start bit
|
||||
sendShort();
|
||||
_delay_ms(BIT_LENGTH);
|
||||
_delay_ms(BIT_LENGTH*3);
|
||||
|
||||
for(int i=0; i<32; i++){
|
||||
if (code &0x80000000){
|
||||
@@ -50,8 +50,8 @@ void sendBlast(void) {
|
||||
}
|
||||
else{
|
||||
sendLong();
|
||||
code<<=1;
|
||||
}
|
||||
code<<=1;
|
||||
}
|
||||
|
||||
//stop bit
|
||||
|
||||
Reference in New Issue
Block a user