Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions software/gigascan/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
.piolibdeps
.clang_complete
.gcc-flags.json
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
7 changes: 7 additions & 0 deletions software/gigascan/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
6 changes: 6 additions & 0 deletions software/gigascan/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"terminal.integrated.env.osx": {
"PATH": "/Users/marco/.platformio/penv/bin:/Users/marco/.platformio/penv:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/CrossPack-AVR/bin",
"PLATFORMIO_CALLER": "vscode"
}
}
4 changes: 4 additions & 0 deletions software/gigascan/src/config.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ e-mail : [email protected]
#define ENCODER_BTN_PIN -44
#define DISPLAY_RESET_BTN_PIN -49 //negative means active internal pull-up

//SDCard for xml files
#define SDCARDCHIP_SELECT_PIN 41 // chipselect of the sdcard interface
#define FILE_BASE_NAME "Scan" // must not be longer than 6 characters

#endif//HARDWARE_VERSION_1_1_0

const char SPLASHSCREEN[] PROGMEM = { "00000000000000000000000000001111111100001100101000000000000000000000000000000000000000000011111111111100110010100000000000000000000000000000000000000000011111111110111110000000000000000000000000000000000000000000001001111111111001111110000000000000000000000000000000000000000001011010111111101111111100000000000000000000000000000000000000000111000011111111111111111000000000000000000000000000000000000000001010011111111111111111100000000000000000000000000000000000000000001001111111111111111110000000000000000000000000000000000000000001000111111111111111100000000000000000000000000000000000000000000100000111110111111111010000000000000000000000000000000000000000000001111111011111111101000000000000000000000000000000000000000000001111111100111111111000000000000000000000000000000000000000000001111101111011111111000000000000000000000000000000000000000000000111110011101111111000000000000000000000000000000000000000000000111111010010001111110000000000000000000000000000000000000000000101111100000000011110000000000000000000000000000000000000000000000111111100000001010000000000000000000000000000000000000000000000111111100000000100000000000000000000000000000000000000000000000001110100000000000000000000000000000000000000000000000000000000000001010000000000000000000000000000000000000000000000000000000001001101000000000000000000000000000000000000000000000000000000000110110000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000011110000001110000000000000000000000000000000000000000000000000001110000001111110000000000000000000000000000000000000000000000000111010001111111000000000000000000000000000000000000000000000000011100000110001110000000000000000000000000000000000000000000000001011000010000011100000000000000000000000000000000000000000000000001100001000001110000000000000000000000000000000000000000000000010111000111000111100100000000000000000000000000000000000000000000011100011110001111000000000000000000000000000000000000000000000000110001111000101101000000000000000000000000000000000000000000000111000010100011110100000000000000000000000000000000000000000000001110000010000111010000000000000000000000000000000000000000000000111000001000011111000000000000000000000000000000000000000000000001110001100001011110000000000000000000000000000000000000000000000111111100000101111010100000000000000000000000000000000000000000000111100000001111101100000000000000000000000000000000000000000000001101000000111110001000000000000000000000000000000000000000000001000000000011110001000000000000000000000000000000000000000000000000000000001111100100000000000000000000000000000000000000000000000000000001011100010000000000000000000000000000000000000000000000000000001100110001000000000000000000000000000000000010000100000000000000000011111100000000000000000000000000000000001110110000000000000001011111110000000000000000000000000000000000001010000000000000000001111110000000000000000000000000000001001101111001000000000000011111111010000000000000000000000000000100010011111100000000000001111111100000000000000000000000000000010111011111110100000000101111111111000000000000000000000000000011001111111111111000000010111111111100000000000000000000000000000110001111111111100000001101111111110000000000000000000000000000001010111111111000000000110011111111000000000000000000000000000000000111111111110101100001001111111100000000000000000000000000000000111111111111110110010000111111110000000000000000000000000000011101111111111111110111100001111110000000000000000000000000000011110111111111111101011110001111110000100000000000000000000000000111111111111111110001111110111110000111110000000000000000000001011111111111111111000011111111111100011011000000000000000000000001111111111111111110011111111100100010011110000000000000000000011111111111111111110011111111110000001000011000000000000000000011101001111111111111100111111111001000110011011000000000000010000111100111111111111110011111111110100011101101100000000000000110110001011111111111111111111111111010001100110010000000000000011010000011111111111111111111111111110000001011110000000000000011101000001111111111111111111111111111100000101110000000000000011110100000011111111111111111111111111110000010110000000000000010011001100010111111111111111111111111110100011011000000000000001101101110001011111111110011111111111111001111000010000000000000110110011000100111111111001111111111111100101110000000000000000000110000100000011111111110011111111111111111110000000000000000000011110010001001111111110011111111111111111100000000000000000000000110110001111111111110000111111111111111110100000000000000000000011111000011111011111100011111111111111111000000000000000000000000001000011111100011110101111111111111011110000000000000000000000000000011111100001111011111111111111101110000000000000000000000000000011111111000010011011111111111111000000000000000000000000000000001111111100100001101011111111111000000000000000000000000000000000111111110011000000000111111111010100000000000000000000000000000011111111101100000001111111111100011000000000000000000000000000001111111111010000000111111111111100110000000000000000000000000000111111111101000000001011111110111010000000000000000000000000000001111111100000000000001111110010001000000000000000000000000000010111111110000000000000100111101100100000000000000000000000000000011111100000000000000000010100000000000000000000000000000000000011111110100000000000000011011100000000000000000000000000000000001111110000000000000000001000010000000000000000000000000000000000100011001100000000000000000000000000000000000000000000000000000010001110100000000000000000000000000000000000000000000000000000001001111100000000000000000000000000000000000000000000000000000000100011110000000000100000000000000000000000000000000000000000000100011111000000101100000000000000000000000000000000000000000000001101111100000001111000000000000000000000000000000000000000000001010111101000001111111000000000000000000000000000000000000000000000011110100001100011100000000000000000000000000000000000000000000000111110000100000111000000000000000000000000000000000000000000000010111000010000011100000000000000000000000000000000000000000000001011110001010000111000000000000000000000000000000000000000000000101101000111100011000000000000000000000000000000000000000000000000111100011110001110000000000000000000000000000000000000000000001001111000111000111010000000000000000000000000000000000000000000000011100000100001100000000000000000000000000000000000000000000000001110000010000110100000000000000000000000000000000000000000000000011100011000001110000000000000000000000000000000000000000000000000111111100010111000000000000000000000000000000000000000000000000011111100000011100000000000000000000000000000000000000000000000000011100000011110000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000011011000000000000000000000000000000000000000000000000000000000101100100000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000001011100000000000000000000000000000000000000000000000001000000001111111000000000000000000000000000000000000000000000010100000001111111000000000000000000000000000000000000000000000011110000000001111101000000000000000000000000000000000000000000011111100010010111111000000000000000000000000000000000000000000000111111101110011111000000000000000000000000000000000000000000000111111110111101111100000000000000000000000000000000000000000000111111111001111111100000000000000000000000000000000000000000000101111111110111111100000000000000000000000000000000000000000000010111111111011111000001000000000000000000000000000000000000000000001111111111111111000100000000000000000000000000000000000000000011111111111111111100100000000000000000000000000000000000000000001111111111111111110010100000000000000000000000000000000000000000111111111111111110000111000000000000000000000000000000000000000001111111101111111010110100000000000000000000000000000000000000000011111100111111111100100000000000000000000000000000000000000000000011111011111111110000000000000000000000000000000000000000001010011001111111111110000000000000000000000000"};
133 changes: 132 additions & 1 deletion software/gigascan/src/panobot.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ e-mail : [email protected]
#include <menuIO/encoderIn.h>
#include <menuIO/keyIn.h>

// SDCard
// --------------------------
// on the Rev 1.1.0 Board you have connect the following Pins from J4
// J4 Pin 1 -> D50 (AT-Mega)
// J4 Pin 2 -> J3 Pin 5
// J4 Pin 4 -> D41 (AT-Mega)
// J4 Pin 6 -> J3 Pin 3
#include <SD.h>
const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
char fileName[] = FILE_BASE_NAME "00.xml";
bool useSDCard = false;
double rollPos = 0;
File sdFile;


using namespace Menu;

//panobot logic & motor control
Expand Down Expand Up @@ -68,6 +83,93 @@ double g_hfov = 0;
double g_vfov = 0;



void xmlWriteHeader() {
if (useSDCard) {
sdFile = SD.open(fileName, FILE_WRITE);
if (sdFile) {
sdFile.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sdFile.println("<papywizard version=\"c\">");
sdFile.println(" <header>");
sdFile.println(" <general>");
sdFile.println(" <title>");
sdFile.println(" Papywizard-Format XML File");
sdFile.println(" </title>");
sdFile.println(" <comment>");
sdFile.println(" Panobot generated file.");
sdFile.println(" </comment>");
sdFile.println(" </general>");
sdFile.println(" <shooting mode=\"preset\">");
sdFile.println(" <headOrientation>");
sdFile.println(" up");
sdFile.println(" </headOrientation>");
sdFile.println(" <cameraOrientation>");
sdFile.println(" landscape");
sdFile.println(" </cameraOrientation>");
sdFile.println(" </shooting>");
sdFile.println(" <camera>");
//sdFile.println(" <sensor coef=\"5.02\" ratio=\"3:2\"/>");
sdFile.println(" </camera>");
sdFile.println(" <lens type=\"rectilinear\">");
sdFile.println(" <focal>");
sdFile.print(" ");
sdFile.println((user_config.focal_length*user_config.crop_factor), DEC);
sdFile.println(" </focal>");
sdFile.println(" </lens>");
sdFile.println(" </header>");
sdFile.println(" <shoot>");
sdFile.close();
}
}
}


void xmlWritePicture() {
if (useSDCard) {
sdFile = SD.open(fileName, FILE_WRITE);
if (sdFile) {
sdFile.print(" <pict bracket=\"1\" id=\""); sdFile.print(g_picturesCount,DEC); sdFile.println("\">");
sdFile.print(" <position pitch=\""); sdFile.print(tiltPos,DEC); sdFile.print("\" roll=\""); sdFile.print(rollPos,DEC); sdFile.print("\" yaw=\""); sdFile.print(panPos,DEC); sdFile.println("\"/>");
sdFile.println(" </pict>");
sdFile.close();
}
}
}

void xmlWriteFooter() {
if (useSDCard) {
sdFile = SD.open(fileName, FILE_WRITE);
if (sdFile) {
sdFile.println(" </shoot>");
sdFile.println("</papywizard>");
sdFile.close();
}
}
}


void sdGetNextFilename() {
if(useSDCard) {
while (SD.exists(fileName)) {
if (fileName[BASE_NAME_SIZE + 1] != '9') {
fileName[BASE_NAME_SIZE + 1]++;
} else if (fileName[BASE_NAME_SIZE] != '9') {
fileName[BASE_NAME_SIZE + 1] = '0';
fileName[BASE_NAME_SIZE]++;
} else {
Serial.println(F("Can't create file name"));
return;
}
}
sdFile = SD.open(fileName, FILE_WRITE);
if (sdFile) {
sdFile.close();
}
}
}



//callback function used by the menu to do the math when updating some values
void updateScanner() {
g_hfov = degrees( 2 * atan2(g_sensorFF_horizontal, user_config.crop_factor * 2 * user_config.focal_length));
Expand Down Expand Up @@ -163,6 +265,8 @@ long startTime = 0;

void runScanCallback()
{
//sdGetNextFilename();
xmlWriteHeader();
g_runScan = true;
g_scanPositionHorizontal = 0;
g_scanPositionVertical = 0;
Expand All @@ -172,6 +276,8 @@ void runScanCallback()

void runSphereCallback()
{
//sdGetNextFilename();
xmlWriteHeader();
g_runScan = true;
modePattern = SPHERICAL;
g_picturesTotal = 0;
Expand Down Expand Up @@ -272,12 +378,17 @@ void stateMachine() {
printScannerStats();
digitalWrite(FOCUS_PIN, LOW);
digitalWrite(SHUTTER_PIN, LOW);

// log Picture to SD Card
xmlWritePicture();

state = updatePosition(state,modePattern);
}
}
if (state == FINISH) {
if (tiltStepper.distanceToGo() == 0 && panStepper.distanceToGo() == 0) {
state = IDLE;
xmlWriteFooter();
}
}
}
Expand Down Expand Up @@ -424,20 +535,36 @@ void splashscreen() {
delay(5000);
}



void setup() {
loadConfig();
options = &myOptions;
//initialize Serial interface
Serial.begin(115200);
while(!Serial);
Serial.println("Panobot");Serial.flush();

// SDCard
delay(200);
Serial.print("Initializing SD card...");
if (!SD.begin(SDCARDCHIP_SELECT_PIN)) {
useSDCard = false;
} else {
useSDCard = true;
sdGetNextFilename();
Serial.println("SDCard found...");
}
delay(500);

//initialize menu
u8g2.begin();
u8g2.setFont(fontName);
encButton.begin();
encoder.begin();
//initialize bot
setupPanoBot();
Serial.println("initialization done.");
splashscreen();
}

Expand All @@ -451,7 +578,11 @@ void loop() {
u8g2.setFontMode(1);
u8g2.setDrawColor(1);
u8g2.setFont(u8g2_font_ncenB12_tr);
u8g2.drawStr(0, 32, "PANOBOT");
if (useSDCard) {
u8g2.drawStr(0, 32, fileName);
} else {
u8g2.drawStr(0, 32, "PANOBOT");
}
u8g2.setFont(fontName);
drawStatus();
u8g2.sendBuffer();
Expand Down