Skip to content

Commit

Permalink
- added some fake headers and symbols for compilation of firmware wit…
Browse files Browse the repository at this point in the history
…h unit tests

- ignore clion ide files
- removed ServoTimer2 library
  • Loading branch information
cemonds committed Feb 24, 2016
1 parent e2b5505 commit d6b068f
Show file tree
Hide file tree
Showing 20 changed files with 449 additions and 271 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
.DS_Store .DS_Store
Software/Firmware/.idea
18 changes: 9 additions & 9 deletions Software/Firmware/CMakeLists.txt
Expand Up @@ -7,25 +7,26 @@ if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-Wall -Wno-deprecated) add_definitions(-Wall -Wno-deprecated)
endif() 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( include_directories(
${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}
) )
#------------------- #-------------------
# set common include folder for module # 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(EXT_PROJECTS_DIR ${PROJECT_SOURCE_DIR}/ext)
set(PROJECT_TEST_DIR ${PROJECT_SOURCE_DIR}/test)


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


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


add_subdirectory(${EXT_PROJECTS_DIR}/gtest) add_subdirectory(${EXT_PROJECTS_DIR}/gtest)


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




if(NOT WIN32) if(NOT WIN32)
target_link_libraries(${PROJECT_TEST_NAME} target_link_libraries(${PROJECT_TEST_NAME}
${PROJECT_LIB_NAME}
${GTEST_LIBS_DIR}/libgtest.a ${GTEST_LIBS_DIR}/libgtest.a
${GTEST_LIBS_DIR}/libgtest_main.a ${GTEST_LIBS_DIR}/libgtest_main.a
) )
Expand Down
5 changes: 0 additions & 5 deletions Software/Firmware/OpenExposer/AccelStepper.h
Expand Up @@ -197,12 +197,7 @@
#define AccelStepper_h #define AccelStepper_h


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


// These defs cause trouble on some versions of Arduino // These defs cause trouble on some versions of Arduino
#undef round #undef round
Expand Down
49 changes: 26 additions & 23 deletions Software/Firmware/OpenExposer/LaserDriver.cpp
@@ -1,17 +1,17 @@
#include <avr/io.h> #include <avr/io.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include "LaserDriver.h" #include "LaserDriver.h"
#include "configuration.h"
#include <util/delay.h> #include <util/delay.h>


uint16_t offset = 2000ul; uint16_t offset = 2000ul;


uint16_t laser_data[512]; laser_buffer_type data;

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


int laser_data_position = 0; size_t laser_data_position = 0;


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


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


while(1){ while(1){


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


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



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

laser_data[81] = 0;

laser_data_position = 0;


data.laser_timings[81] = 0;

laser_data_position = 0;
} }




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


create_test_pattern(); create_test_pattern();


SET_DDR(LASER); SET_DDR(LASER);


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


TCCR1B = 1; TCCR1B = 1;

} }


void fill_laser_buffer(long distance){ void fill_laser_buffer(long distance){

if (distance == 0) { if (distance == 0) {
laser_data[laser_data_position] = 0; data.positions[laser_data_position] = 0;
laser_data_position = 0; convert_positions_to_timings();
laser_data_position = 0;
} else { } else {
laser_data[laser_data_position] = distance * LASER_POINT_SCALER; data.positions[laser_data_position] = distance;
laser_data_position++; laser_data_position++;
} }
delay(1); 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 // Turn Laser Timer on and activate Opto Capture
Expand Down
14 changes: 9 additions & 5 deletions Software/Firmware/OpenExposer/LaserDriver.h
@@ -1,21 +1,25 @@
#ifndef LASERDRIVER_H #ifndef LASERDRIVER_H
#define 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; 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 init_laser_driver();
void laser_on(); void laser_on();
void laser_off(); void laser_off();
void expose_line(int time); void expose_line(int time);
void set_exposing_cycles(uint8_t cycles); void set_exposing_cycles(uint8_t cycles);
void fill_laser_buffer(long distance); void fill_laser_buffer(long distance);
void create_test_pattern(); void create_test_pattern();
void convert_positions_to_timings();


#endif #endif


1 change: 0 additions & 1 deletion Software/Firmware/OpenExposer/MotorDriver.cpp
@@ -1,6 +1,5 @@


#include "configuration.h" #include "configuration.h"
//#include "ServoTimer2.h"
#include "MotorDriver.h" #include "MotorDriver.h"
#include "AccelStepper.h" #include "AccelStepper.h"
#include "LaserDriver.h" #include "LaserDriver.h"
Expand Down
4 changes: 0 additions & 4 deletions Software/Firmware/OpenExposer/MotorDriver.h
@@ -1,11 +1,7 @@
#ifndef STEPPERCONTROLLER_H #ifndef STEPPERCONTROLLER_H
#define STEPPERCONTROLLER_H #define STEPPERCONTROLLER_H


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


// Helper Macro degrees to Microseconds for Timer2 Servo // Helper Macro degrees to Microseconds for Timer2 Servo
#define degreesToMS( _degrees) (_degrees * 6 + 900) #define degreesToMS( _degrees) (_degrees * 6 + 900)
Expand Down
3 changes: 0 additions & 3 deletions Software/Firmware/OpenExposer/OpenExposer.ino 100755 → 100644
@@ -1,14 +1,11 @@
#include "configuration.h" #include "configuration.h"
#include <Servo.h>
#include "LaserDriver.h" #include "LaserDriver.h"
#include "MotorDriver.h" #include "MotorDriver.h"
#include "Interpreter.h" #include "Interpreter.h"


void setup(){ void setup(){




Servo vat_servo;

Serial.begin(BAUD); Serial.begin(BAUD);


init_motor_driver(); init_motor_driver();
Expand Down
132 changes: 0 additions & 132 deletions Software/Firmware/OpenExposer/ServoTimer2.cpp

This file was deleted.

0 comments on commit d6b068f

Please sign in to comment.