Permalink
Browse files

- added some fake headers and symbols for compilation of firmware wit…

…h unit tests

- ignore clion ide files
- removed ServoTimer2 library
  • Loading branch information...
cemonds committed Feb 24, 2016
1 parent e2b5505 commit d6b068f0a2cee1c1d5f55426e379c4df6fc1391e
@@ -1 +1,2 @@
.DS_Store
Software/Firmware/.idea
@@ -7,25 +7,26 @@ if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-Wall -Wno-deprecated)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pthread")

include_directories(
${PROJECT_SOURCE_DIR}
)
#-------------------
# set common include folder for module
#-------------------
set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/include)
set(TEST_INCLUDES ${PROJECT_SOURCE_DIR}/test-include)
set(EXT_PROJECTS_DIR ${PROJECT_SOURCE_DIR}/ext)
set(PROJECT_TEST_DIR ${PROJECT_SOURCE_DIR}/test)

#-------------------
# Module source
#-------------------
#set(PROJECT_LIB_NAME ${PROJECT_NAME_STR}_impl)
set(PROJECT_LIB_NAME ${PROJECT_NAME_STR}_impl)

#include_directories(${COMMON_INCLUDES})
#file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp)
#add_library(${PROJECT_LIB_NAME} ${SRC_FILES})
file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/OpenExposer/*.cpp)
add_library(${PROJECT_LIB_NAME} ${SRC_FILES})

add_subdirectory(${EXT_PROJECTS_DIR}/gtest)

@@ -34,16 +35,15 @@ add_subdirectory(${EXT_PROJECTS_DIR}/gtest)
#-------------------
enable_testing()
set(PROJECT_TEST_NAME ${PROJECT_NAME}_test)
include_directories(${GTEST_INCLUDE_DIRS} ${COMMON_INCLUDES})
set(TEST_SRC_FILES
test/TestLaserDriver.cpp
)
include_directories(${GTEST_INCLUDE_DIRS} ${TEST_INCLUDES} ${PROJECT_TEST_DIR})
set(TEST_SRC_FILES test/TestLaserDriver.cpp test/FakeSerial.cpp test/ArduinoSymbols.cpp)
add_executable(${PROJECT_TEST_NAME} ${TEST_SRC_FILES})
add_dependencies(${PROJECT_TEST_NAME} googletest)


if(NOT WIN32)
target_link_libraries(${PROJECT_TEST_NAME}
${PROJECT_LIB_NAME}
${GTEST_LIBS_DIR}/libgtest.a
${GTEST_LIBS_DIR}/libgtest_main.a
)
@@ -197,12 +197,7 @@
#define AccelStepper_h

#include <stdlib.h>
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#include <wiring.h>
#endif

// These defs cause trouble on some versions of Arduino
#undef round
@@ -1,17 +1,17 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include "LaserDriver.h"
#include "configuration.h"
#include <util/delay.h>

uint16_t offset = 2000ul;

uint16_t laser_data[512];
laser_buffer_type data;

uint16_t begin_delay = 3800+offset;
uint16_t end_delay = 47500ul;
uint16_t sync_timeout_delay = 60000ul;

int laser_data_position = 0;
size_t laser_data_position = 0;

static uint8_t laser_state;
volatile uint8_t write_line_enable = 0;
@@ -49,7 +49,7 @@ ISR(TIMER1_CAPT_vect){

void laser_write_line(){

uint16_t * data = laser_data;
uint16_t * timings = data.laser_timings;

//wait for OCR0A compare match (begin of line, laser off)
while((TIFR1 & (1<<OCF1A)) == 0);
@@ -62,7 +62,7 @@ void laser_write_line(){

while(1){

uint16_t tmp = *data++;
uint16_t tmp = *timings++;

if(tmp == 0){ //end mark?
break; //yes: end line
@@ -154,15 +154,13 @@ ISR(TIMER1_COMPB_vect){
// fill data table with test pattern
void create_test_pattern(){


for(laser_data_position=0;laser_data_position < 80; laser_data_position++){
laser_data[laser_data_position] = 500-laser_data_position;
}

laser_data[81] = 0;

laser_data_position = 0;
for(laser_data_position=0;laser_data_position < 80; laser_data_position++){
data.laser_timings[laser_data_position] = 500-laser_data_position;
}

data.laser_timings[81] = 0;

laser_data_position = 0;
}


@@ -188,26 +186,31 @@ void init_laser_driver(){

create_test_pattern();

SET_DDR(LASER);
SET_DDR(LASER);

SET_DDR(LASER_PWM);
SET_DDR(LASER_PWM);
OUTPUT_ON(LASER_PWM);

TCCR1B = 1;

TCCR1B = 1;
}

void fill_laser_buffer(long distance){

if (distance == 0) {
laser_data[laser_data_position] = 0;
laser_data_position = 0;
data.positions[laser_data_position] = 0;
convert_positions_to_timings();
laser_data_position = 0;
} else {
laser_data[laser_data_position] = distance * LASER_POINT_SCALER;
laser_data_position++;
data.positions[laser_data_position] = distance;
laser_data_position++;
}
delay(1);

}

void convert_positions_to_timings() {
for(int i = 0; i < laser_data_position; ++i) {
data.laser_timings[i] = data.positions[i] * LASER_POINT_SCALER;
}
data.laser_timings[laser_data_position] = 0;
}

// Turn Laser Timer on and activate Opto Capture
@@ -1,21 +1,25 @@
#ifndef LASERDRIVER_H
#define LASERDRIVER_H
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

#include <Arduino.h>

#include "configuration.h"

extern uint8_t exposing_done;

typedef union {
uint32_t positions[LASER_POSITIONS_BUFFER_SIZE];
uint16_t laser_timings[LASER_POSITIONS_BUFFER_SIZE];
} laser_buffer_type;

void init_laser_driver();
void laser_on();
void laser_off();
void expose_line(int time);
void set_exposing_cycles(uint8_t cycles);
void fill_laser_buffer(long distance);
void create_test_pattern();
void convert_positions_to_timings();

#endif

@@ -1,6 +1,5 @@

#include "configuration.h"
//#include "ServoTimer2.h"
#include "MotorDriver.h"
#include "AccelStepper.h"
#include "LaserDriver.h"
@@ -1,11 +1,7 @@
#ifndef STEPPERCONTROLLER_H
#define STEPPERCONTROLLER_H

#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

// Helper Macro degrees to Microseconds for Timer2 Servo
#define degreesToMS( _degrees) (_degrees * 6 + 900)
@@ -1,14 +1,11 @@
#include "configuration.h"
#include <Servo.h>
#include "LaserDriver.h"
#include "MotorDriver.h"
#include "Interpreter.h"

void setup(){


Servo vat_servo;

Serial.begin(BAUD);

init_motor_driver();

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit d6b068f

Please sign in to comment.